• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# SimpleJSON.JSONArray类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中SimpleJSON.JSONArray的典型用法代码示例。如果您正苦于以下问题:C# JSONArray类的具体用法?C# JSONArray怎么用?C# JSONArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JSONArray类属于SimpleJSON命名空间,在下文中一共展示了JSONArray类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: AsStringArray

 public static string[] AsStringArray(JSONArray arrayJson)
 {
     string[] array = new string[arrayJson.Count];
     int index = 0;
     foreach(JSONNode node in arrayJson){
         array[index] = (string)node.ToString();
         index+=1;
     }
     return array;
 }
开发者ID:claytantor,项目名称:shadow-haven-unity,代码行数:10,代码来源:JSONUtils.cs


示例2: convertPersistentListToJSONArray

				public static JSONArray convertPersistentListToJSONArray (List<JSONPersistent> list)
				{		
						JSONArray jArray = new JSONArray ();
		
						foreach (JSONPersistent persist in list) {
								jArray.Add (persist.getDataClass ());
						}

						return jArray;
				}
开发者ID:DomDomHaas,项目名称:JSONPersistency,代码行数:10,代码来源:JSONPersistentArray.cs


示例3: convertJSONArrayToPersistentList

				public static List<JSONPersistent> convertJSONArrayToPersistentList (JSONArray jArray, Type persistentType)
				{
						List<JSONPersistent> list = new List<JSONPersistent> ();

						for (int i = 0; i < jArray.Count; i++) {

								JSONPersistent persist = Activator.CreateInstance (persistentType) as JSONPersistent;
								persist.setClassData (jArray [i].AsObject);
								list.Add (persist);
						}

						return list;
				}
开发者ID:DomDomHaas,项目名称:JSONPersistency,代码行数:13,代码来源:JSONPersistentArray.cs


示例4: JSONLazyCreator

		public override JSONNode this [int aIndex]
		{
			get {
				return new JSONLazyCreator (this);
			}
			set {
				var tmp = new JSONArray ();
				tmp.Add (value);
				Set (tmp);
			}
		}
开发者ID:MirandaDora,项目名称:mbc,代码行数:11,代码来源:SimpleJSON.cs


示例5: getKeyMapStringArraysFromKeyMapJSON

 //Helper function that gets a keymap from a JSON array (assumed to be 2D array of strings)
 public static List<string[]> getKeyMapStringArraysFromKeyMapJSON(JSONArray keyMap)
 {
     JSONArray keysJSON = keyMap[0].AsArray;
     JSONArray commandsJSON = keyMap[1].AsArray;
     string[] keys = new string[keysJSON.Count];
     for (int i = 0; i < keysJSON.Count; i++)
         keys[i] = keysJSON[i];
     string[] commands = new string[commandsJSON.Count];
     for (int i = 0; i < commandsJSON.Count; i++)
         commands[i] = commandsJSON[i];
     List<string[]> output = new List<string[]>();
     output.Add(keys);
     output.Add(commands);
     return output;
 }
开发者ID:ikids-research,项目名称:ikids-newborn-cognitive-unity,代码行数:16,代码来源:JSONDataLoader.cs


示例6: GetExtJson

        /*
         * {
                "type": "group_info", //标记
                "group": //group 信息
                 {
                    "member":
                    [//成员
                        {
                            "uid": ""//用户id
                        },
                        ...
                    ],
                    "vid": "", //场馆id
                    "name": "",//..名字
                    "address": "",//..地址
                    "time": "",//..时间
                    "latitude": "",//..经度
                    "longtitude": "",//..纬度
                    "state": "",//..状态 3种状态 0 是未预订 2是预订 1是投票状态
                    "max": ""//..最大成员数 默认10
                }
            }
         */
        public string GetExtJson(string groupID)
        {
            Monitor.Enter(userGroupDict);
            try
            {
                SportMatchGroup group = groupList.Find(a => { return a.groupID == groupID; });
                Venue venue = group.venue;

                JSONClass jc = new JSONClass();
                jc.Add("type", new JSONData("group_info"));
                JSONClass jc_1 = new JSONClass();
                JSONArray ja_1_1 = new JSONArray();
                var itr = userGroupDict.GetEnumerator();
                while (itr.MoveNext())
                {
                    string groupid = itr.Current.Value;
                    if (groupid != groupID)
                        continue;
                    string uuid = itr.Current.Key;
                    JSONClass jc_1_1_i = new JSONClass();
                    jc_1_1_i.Add("uid", new JSONData(uuid));
                    ja_1_1.Add(jc_1_1_i);
                }
                jc_1.Add("member", ja_1_1);
                if (venue == null)
                {
                    jc_1.Add("vid", new JSONData(""));
                    jc_1.Add("name", new JSONData(""));
                    jc_1.Add("address", new JSONData(""));
                    jc_1.Add("time", new JSONData(""));
                    jc_1.Add("latitude", new JSONData(""));
                    jc_1.Add("longtitude", new JSONData(""));
                    jc_1.Add("state", new JSONData(0));
                }
                else
                {
                    jc_1.Add("vid", new JSONData(venue.id));
                    jc_1.Add("name", new JSONData(venue.name));
                    jc_1.Add("address", new JSONData(venue.address));
                    jc_1.Add("time", new JSONData(venue.time));
                    jc_1.Add("latitude", new JSONData(venue.latitude));
                    jc_1.Add("longtitude", new JSONData(venue.longitude));
                    jc_1.Add("state", new JSONData(2));
                }
                jc_1.Add("max", new JSONData(10));
                jc.Add("group", jc_1);
                return jc.ToJSON(0);
            }
            finally
            {
                Monitor.Exit(userGroupDict);
            }
        }
开发者ID:y85171642,项目名称:ESportServer,代码行数:76,代码来源:SportMatchManager.cs


示例7: SendMessage

        /*
         *{
                "target_type":"users",     // users 给用户发消息。chatgroups 给群发消息,chatrooms 给聊天室发消息
                "target":["testb","testc"], // 注意这里需要用数组,数组长度建议不大于20,即使只有
                                            // 一个用户u1或者群组,也要用数组形式 ['u1'],给用户发
                                            // 送时数组元素是用户名,给群组发送时数组元素是groupid
                "msg":{  //消息内容
                    "type":"txt",  // 消息类型,不局限与文本消息。任何消息类型都可以加扩展消息
                    "msg":"消息"    // 随意传入都可以
                },
                "from":"testa",  //表示消息发送者。无此字段Server会默认设置为"from":"admin",有from字段但值为空串("")时请求失败
                "ext":{   //扩展属性,由APP自己定义。可以没有这个字段,但是如果有,值不能是"ext:null"这种形式,否则出错
                    "attr1":"v1"   // 消息的扩展内容,可以增加字段,扩展消息主要解析不分。
                }
            }
         */
        public string SendMessage(string targetType, string[] targetID, string msgType, string msgText, string fromUUID, string extJson = null)
        {
            JSONClass jc = new JSONClass();
            jc.Add("target_type", JD(targetType));
            JSONArray ja = new JSONArray();
            foreach (string tID in targetID)
            {
                ja.Add(JD(tID));
            }
            jc.Add("target", ja);
            JSONClass jmsg = new JSONClass();
            jmsg.Add("type", JD(msgType));
            jmsg.Add("msg", JD(msgText));
            jc.Add("msg", jmsg);
            if (fromUUID != null)
                jc.Add("from", fromUUID);
            if (extJson != null)
                jc.Add("ext", JSON.Parse(extJson));

            string postData = jc.ToJSON(0);
            string result = ReqUrl(easeMobUrl + "messages", "POST", postData, token);
            return result;
        }
开发者ID:y85171642,项目名称:ESportServer,代码行数:39,代码来源:EaseXin.cs


示例8: Serialize

        public static void Serialize(JSONClass jc, object obj, bool serializeStatic = false)
        {
            foreach (FieldInfo mi in obj.GetType().GetFields())
            {
                if (mi.GetCustomAttributes(typeof(NonSerializedAttribute), true).Length > 0)
                    continue;

                if (!serializeStatic && mi.IsStatic)
                    continue;

                if (mi.FieldType.IsArray)
                {
                    IEnumerable arrobjs = (IEnumerable)mi.GetValue(obj);

                    JSONArray arr = new JSONArray();

                    if (typeof(IJSONSerializable).IsAssignableFrom(mi.FieldType.GetElementType()))
                    {
                        foreach (object aobj in arrobjs)
                        {
                            JSONClass cls = new JSONClass();
                            ((IJSONSerializable)aobj).OnSerialize(cls);
                            arr.Add(cls);
                        }
                    }
                    else
                    {
                        if (mi.FieldType.GetElementType() == typeof(GameObject))
                        {
                            foreach (object aobj in arrobjs)
                            {
                                arr.Add(AssetUtility.GetAssetPath((GameObject)aobj));
                            }
                        }
                        else
                        {
                            foreach (object aobj in arrobjs)
                            {
                                arr.Add(aobj.ToString());
                            }
                        }
                    }
                    jc[mi.Name] = arr;

                }
                else
                {
                    if (typeof(IJSONSerializable).IsAssignableFrom(mi.FieldType))
                    {
                        JSONClass cls = new JSONClass();
                        (mi.GetValue(obj) as IJSONSerializable).OnSerialize(cls);
                        jc[mi.Name] = cls;
                    }
                    else
                    {
                        if (mi.FieldType == typeof(GameObject))
                        {
                            jc[mi.Name] = AssetUtility.GetAssetPath((GameObject)mi.GetValue(obj));
                        }
                        else if (mi.FieldType == typeof(Color))
                        {
                            Color c = (Color)mi.GetValue(obj);
                            jc[mi.Name] = SerializeColor(c);
                        }
                        else if (mi.FieldType == typeof(Vector4))
                        {
                            Vector4 c = (Vector4)mi.GetValue(obj);
                            jc[mi.Name] = SerializeVector4(c);
                        }
                        else if (mi.FieldType == typeof(Vector3))
                        {
                            Vector3 c = (Vector3)mi.GetValue(obj);
                            jc[mi.Name] = SerializeVector3(c);
                        }
                        else if (mi.FieldType == typeof(Vector2))
                        {
                            Vector2 c = (Vector2)mi.GetValue(obj);
                            jc[mi.Name] = SerializeVector2(c);
                        }
                        else if (mi.FieldType == typeof(TimeSpan))
                        {
                            jc[mi.Name] = ((TimeSpan)mi.GetValue(obj)).ToString();
                        }
                        else if(mi.FieldType.IsEnum)
                        {
                            Enum v = (Enum)mi.GetValue(obj);
                            jc[mi.Name] = string.Format("{0} {1}", v.GetType().Name, v.ToString());
                        }
                        else
                        {
                            object v = mi.GetValue(obj);
                            if (mi.FieldType == typeof(string))
                                v = "";

                            if (v != null)
                                jc[mi.Name] = mi.GetValue(obj).ToString();
                            else
                                Debug.LogError("[JSONSerialization] Cannot save field: " + mi.Name + " due to its (null)");
                        }
                    }
//.........这里部分代码省略.........
开发者ID:RollySeth,项目名称:MagicaVoxelUnity,代码行数:101,代码来源:ISerializable.cs


示例9: setJSONArray

				/// <summary>
				/// replaces the existing JSONArray
				/// </summary>
				/// <param name="newArray">New array.</param>
				public void setJSONArray (JSONArray newArray)
				{
						persistentArray = newArray;
				}
开发者ID:DomDomHaas,项目名称:JSONPersistency,代码行数:8,代码来源:JSONPersistentArray.cs


示例10: Save

        private static void Save(Assembly asm)
        {
            var mod = GetModFromAssembly(asm);
              if (mod == null)
              {
            throw new InvalidOperationException("Cannot save configuration: "
              + "Failed to determine mod");
              }

              var modName = mod.Mod.Name;

              if (!configs.ContainsKey(modName))
              {
            configs.Add(modName, new Dictionary<string, Value>());
              }

              var config = configs[modName];
              var keys = config.Keys.ToArray();
              var root = new JSONArray();
              for (int i = 0; i < keys.Length; i++)
              {
            var obj = new JSONClass();
            obj["key"] = keys[i];
            obj["value"]["type"] = config[keys[i]].type;
            obj["value"]["value"] = config[keys[i]].value.ToString();
            root[i] = obj;
              }

              var json = root.ToJSON(0);
              var path = Application.dataPath + "/Mods/Config/" + modName + ".json";

              Directory.CreateDirectory(Application.dataPath + "/Mods/Config/");

              using (var writer = new StreamWriter(File.Open(path, FileMode.Create)))
              {
            writer.Write(json);
              }
        }
开发者ID:buckle2000,项目名称:besiege-modloader,代码行数:38,代码来源:Configuration.cs


示例11: ConvertListToJson

        private string ConvertListToJson(List<String> list)
        {
            if (list == null) {
                return null;
            }

            var jsonArray = new JSONArray ();

            foreach (var listItem in list) {
                jsonArray.Add (new JSONData (listItem));
            }

            return jsonArray.ToString ();
        }
开发者ID:tengontheway,项目名称:unity_sdk,代码行数:14,代码来源:AdjustiOS.cs


示例12: DeserializeComponents

        public static void DeserializeComponents(JSONArray components, GameObject obj)
        {
            foreach (JSONNode node in components.Childs)
            {
                string clsName = node["_meta_cls"];
                Type t = Type.GetType("AU." + clsName);
                IJSONSerializable s = obj.AddComponent(t) as IJSONSerializable;

                s.OnDeserialize(node);
            }
        }
开发者ID:RollySeth,项目名称:MagicaVoxelUnity,代码行数:11,代码来源:ISerializable.cs


示例13: SerializeComponents

        public static JSONArray SerializeComponents(GameObject obj)
        {
            JSONArray a = new JSONArray();
            IJSONSerializable[] serializables = obj.GetInterfaces<IJSONSerializable>().ToArray();
            foreach (IJSONSerializable hs in serializables)
            {
                JSONClass hsNode = new JSONClass();

                hs.OnSerialize(hsNode);

                hsNode["_meta_cls"] = hs.GetType().Name;

                a.Add(hsNode);
            }
            return a;
        }
开发者ID:RollySeth,项目名称:MagicaVoxelUnity,代码行数:16,代码来源:ISerializable.cs


示例14: Add

		public override void Add (JSONNode aItem)
		{
			var tmp = new JSONArray ();
			tmp.Add (aItem);
			Set (tmp);
		}
开发者ID:MirandaDora,项目名称:mbc,代码行数:6,代码来源:SimpleJSON.cs


示例15: Deserialize

		public static JSONNode Deserialize (System.IO.BinaryReader aReader)
		{
			JSONBinaryTag type = (JSONBinaryTag)aReader.ReadByte ();
			switch (type) {
			case JSONBinaryTag.Array:
			{
				int count = aReader.ReadInt32 ();
				JSONArray tmp = new JSONArray ();
				for (int i = 0; i < count; i++)
					tmp.Add (Deserialize (aReader));
				return tmp;
			}
			case JSONBinaryTag.Class:
			{
				int count = aReader.ReadInt32 ();                
				JSONClass tmp = new JSONClass ();
				for (int i = 0; i < count; i++) {
					string key = aReader.ReadString ();
					var val = Deserialize (aReader);
					tmp.Add (key, val);
				}
				return tmp;
			}
			case JSONBinaryTag.Value:
			{
				return new JSONData (aReader.ReadString ());
			}
			case JSONBinaryTag.IntValue:
			{
				return new JSONData (aReader.ReadInt32 ());
			}
			case JSONBinaryTag.DoubleValue:
			{
				return new JSONData (aReader.ReadDouble ());
			}
			case JSONBinaryTag.BoolValue:
			{
				return new JSONData (aReader.ReadBoolean ());
			}
			case JSONBinaryTag.FloatValue:
			{
				return new JSONData (aReader.ReadSingle ());
			}
				
			default:
			{
				throw new Exception ("Error deserializing JSON. Unknown tag: " + type);
			}
			}
		}
开发者ID:MirandaDora,项目名称:mbc,代码行数:50,代码来源:SimpleJSON.cs


示例16: SetListStart

    protected IEnumerator SetListStart()
    {
        string aLink;
        WWW aWWW;
        string aResponse;
        SimpleJSON.JSONClass aJsonClass;

        aLink = "https://goo.gl/...ID...";
        aWWW = new WWW(aLink);
        yield return aWWW;

        if (aWWW.error == null)
        {
            aResponse = aWWW.text;
        /*
         * Hard-coded JSON data feed example
         *
         * {"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$openSearch":"http://a9.com/-/spec/opensearchrss/1.0/","xmlns$gsx":"http://schemas.google.com/spreadsheets/2006/extended","id":{"$t":"https://spreadsheets.google.com/feeds/list/.../od6/public/values"},"updated":{"$t":"2015-07-12T00:00:00.000Z"},"category":[{"scheme":"http://schemas.google.com/spreadsheets/2006","term":"http://schemas.google.com/spreadsheets/2006#list"}],"title":{"type":"text","$t":"Sheet1"},"link":[{"rel":"alternate","type":"application/atom+xml","href":"https://docs.google.com/spreadsheets/d/.../pubhtml"},{"rel":"http://schemas.google.com/g/2005#feed","type":"application/atom+xml","href":"https://spreadsheets.google.com/feeds/list/.../od6/public/values"},{"rel":"http://schemas.google.com/g/2005#post","type":"application/atom+xml","href":"https://spreadsheets.google.com/feeds/list/.../od6/public/values"},{"rel":"self","type":"application/atom+xml","href":"https://spreadsheets.google.com/feeds/list/.../od6/public/values?alt\u003djson"}],"author":[{"name":{"$t":"spreadsheet2app"},"email":{"$t":"[email protected]"}}],"openSearch$totalResults":{"$t":"2"},"openSearch$startIndex":{"$t":"1"},"entry":[{"id":{"$t":"https://spreadsheets.google.com/feeds/list/.../od6/public/values/cokwr"},"updated":{"$t":"2015-07-12T00:00:00.000Z"},"category":[{"scheme":"http://schemas.google.com/spreadsheets/2006","term":"http://schemas.google.com/spreadsheets/2006#list"}],"title":{"type":"text","$t":"1"},"content":{"type":"text","$t":"title: Item One T, description: Item One D, imagelink: http://drive.google.com/uc?export\u003dview\u0026id\u003d__ID__\u0026, lastupdated: 7/13/2015"},"link":[{"rel":"self","type":"application/atom+xml","href":"https://spreadsheets.google.com/feeds/list/.../od6/public/values/cokwr"}],"gsx$id":{"$t":"1"},"gsx$title":{"$t":"Item One T"},"gsx$description":{"$t":"Item One D"},"gsx$imagelink":{"$t":"http://drive.google.com/uc?export\u003dview\u0026id\u003d__ID__\u0026"},"gsx$lastupdated":{"$t":"7/13/2015"}},{"id":{"$t":"https://spreadsheets.google.com/feeds/list/.../od6/public/values/cpzh4"},"updated":{"$t":"2015-07-12T00:00:00.000Z"},"category":[{"scheme":"http://schemas.google.com/spreadsheets/2006","term":"http://schemas.google.com/spreadsheets/2006#list"}],"title":{"type":"text","$t":"2"},"content":{"type":"text","$t":"title: Item Two T, description: Item Two D, imagelink: http://drive.google.com/uc?export\u003dview\u0026id\u003d__ID__\u0026, lastupdated: 7/13/2015"},"link":[{"rel":"self","type":"application/atom+xml","href":"https://spreadsheets.google.com/feeds/list/.../od6/public/values/cpzh4"}],"gsx$id":{"$t":"2"},"gsx$title":{"$t":"Item Two T"},"gsx$description":{"$t":"Item Two D"},"gsx$imagelink":{"$t":"http://drive.google.com/uc?export\u003dview\u0026id\u003d__ID__\u0026"},"gsx$lastupdated":{"$t":"7/13/2015"}}]}}
         *
         */
            aJsonClass = (SimpleJSON.JSONNode.Parse (""+aResponse) as SimpleJSON.JSONClass);
            MyList = aJsonClass["feed"]["entry"].AsArray;
            SetButtons();
        }
        else
        {
            aResponse = aWWW.error;
            MyList = (SimpleJSON.JSONNode.Parse ("[]") as SimpleJSON.JSONArray);
        }
        aWWW.Dispose();
        yield return null;
    }
开发者ID:walointernationallimited,项目名称:spreadsheet2app,代码行数:32,代码来源:Spreadsheet2App_MainCamera.cs


示例17: UpdateHazards

 private void UpdateHazards()
 {
     if (nowObject[1].AsDouble <= MediaPlayer.PlayPosition.TotalSeconds + ((mCarPosition.Y + mHazard.Height * 0.7) / mVelocityY))
     { // time for a new hazard to enter the stage
         if (noteCounter < hitObjects.Count)
         {
             AddHazard();
             noteCounter++;
             if (noteCounter == hitObjects.Count)
                 return;
             nowObject = hitObjects[noteCounter].AsArray; // nowObject = next note
         }
     }
 }
开发者ID:Xivid,项目名称:RhythmHit,代码行数:14,代码来源:Game1.cs


示例18: StartGame

        protected void StartGame()
        {
            mRoadY[0] = 0;
            mRoadY[1] = -1 * mRoad.Height;

            mScore = 0;
            mHazardsPerfect = mHazardsGood = mHazardsMiss = 0;
            mHazardsCombo = 0;
            mVelocityY = (1 + difficulty) * 300; // velocity increases with difficulty
            mCurrentRoadIndex = 0; // the scroll starts from the first road
            mHazards.Clear();

            // Read beatmap of the chosen music with the chosen difficulty
            String musicname = musicNames[musicChosen];
            beatmap = BeatmapJson[musicChosen];
            switch (difficulty)
            {
                case 0:
                    hitObjects = beatmap["GameObject"]["Easy"].AsArray;
                    break;
                case 1:
                    hitObjects = beatmap["GameObject"]["Normal"].AsArray;
                    break;
                case 2:
                    hitObjects = beatmap["GameObject"]["Hard"].AsArray;
                    break;
                default:
                    return;
            }

            try
            {
                hitSE = Content.Load<SoundEffect>("Music/" + musicname + "/hit");
            }
            catch (Exception e) // load fail
            {
                this.Exit();
            }

            mCurrentState = State.Running;

            noteCounter = 0;
            nowObject = hitObjects[0].AsArray;

            MediaPlayer.Play(mMusics[musicChosen]);
            MediaPlayer.Volume = 1.0f; // reset the volume to 1.0f, in case the player starts the game when the preview music is fading in or fading out
        }
开发者ID:Xivid,项目名称:RhythmHit,代码行数:47,代码来源:Game1.cs



注:本文中的SimpleJSON.JSONArray类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# SimpleJSON.JSONClass类代码示例发布时间:2022-05-26
下一篇:
C# SimpleInjector.Container类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap