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

C# JsonData类代码示例

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

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



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

示例1: ItemsToFileJSon

    private List<Item> ItemsToFileJSon(JsonData sourceData)
    {
        int LengthData = sourceData.Count;
        List<Item> itemsToGetted = new List<Item>();

        for (int i = 0; i < LengthData; i++)
        {
            Item itemGettedTmp = new Item()
            {
                Id = (int)sourceData[i]["Id"],
                Name = sourceData[i]["Name"].ToString(),
                Description = sourceData[i]["Description"].ToString(),
                Intensity = (int)sourceData[i]["Intensity"],
                TypeItem = (e_itemType)((int)sourceData[i]["Type"]),
                ElementTarget = (e_element)((int)sourceData[i]["Element"]),
                LevelRarity = (e_itemRarity)((int)sourceData[i]["Rarity"]),
                IsStackable = (bool)sourceData[i]["Stackable"],
                Sprite = Item.AssignResources(sourceData[i]["Sprite"].ToString())
            };

            itemsToGetted.Add(itemGettedTmp);
        }

        return itemsToGetted;
    }
开发者ID:noctisyounis,项目名称:Playground2015_Project3,代码行数:25,代码来源:ItemManager.cs


示例2: InitializeList

    // 初始化部件列表, 同时初始化第一种部件类型的清单列表(包括图标和文字)
    public void InitializeList(JsonData data)
    {
        ClearAll ();
        JsonData jsonArray = data["data_list"];
        for (int i = 0; i < jsonArray.Count; i++) {
            GameObject item = GameObject.FindGameObjectWithTag("componentitem");
            GameObject newItem = Instantiate(item) as GameObject;
            newItem.GetComponent<ComponentItem>().componentId = (int)jsonArray[i]["id"];
            newItem.GetComponent<ComponentItem>().componentName = jsonArray[i]["name"].ToString();
            newItem.GetComponent<ComponentItem>().componentLabel.text = jsonArray[i]["name"].ToString();
            newItem.GetComponent<ComponentItem>().name = jsonArray[i]["name"].ToString();
            newItem.GetComponent<RectTransform>().localScale = Vector3.one;
            newItem.transform.SetParent (gridLayout.transform);
            newItem.GetComponent<RectTransform>().localScale = newItem.transform.parent.localScale;
            componentItems.Add(newItem);
            Color temp = newItem.GetComponent<ComponentItem>().triangle.color;
            if (i == 0) {
                temp.a = 255f;
            } else {
                temp.a = 0f;
            }
            newItem.GetComponent<ComponentItem>().triangle.color = temp;

            newItem.SetActive (true);
        }
        SetContentWidth ();
        if (jsonArray.Count > 0) {
            WWWForm wwwForm = new WWWForm();
            wwwForm.AddField("api_type", 3);
            wwwForm.AddField("id", (int)jsonArray[0]["id"]);
            GetComponent<HttpServer>().SendRequest(Constant.ReuestUrl, wwwForm, new HttpServer.GetJson(typeScrollView.InitializeList));
        }
    }
开发者ID:Jermmy,项目名称:CarModel,代码行数:34,代码来源:ComponentScrollView.cs


示例3: DoRequest

        protected override void DoRequest(AjaxContext context, JsonData input, JsonData output)
        {
            // get...
            AjaxValidator validator = new AjaxValidator();
            string username = validator.GetRequiredString(input, "username");
            string password = validator.GetRequiredString(input, "password");

            // ok?
            if (validator.IsOk)
            {
                // get...
                User user = User.GetByUsername(context, username);
                if (user != null)
                {
                    // check...
                    if (user.CheckPassword(password))
                    {
                        // create an access token...
                        Token token = Token.CreateToken(context, user);
                        if (token == null)
                            throw new InvalidOperationException("'token' is null.");

                        // set...
                        output["token"] = token.TheToken;
                    }
                    else
                        validator.AddError("Password is invalid.");
                }
                else
                    validator.AddError("Username is invalid.");
            }

            // set...
            validator.Apply(output);
        }
开发者ID:mbrit,项目名称:dotnet-streetfoo,代码行数:35,代码来源:HandleLogon.ashx.cs


示例4: ProcessRequest

        public void ProcessRequest(HttpContext context)
        {
            string json = null;
            using (Stream stream = context.Request.InputStream)
            {
                StreamReader reader = new StreamReader(stream);
                json = reader.ReadToEnd();
            }

            // load...
            JsonData input = new JsonData(json);
            JsonData output = new JsonData();
            try
            {
                DoRequest(input, output);

                // did we get output?
                if (!(output.ContainsKey("isOk")))
                    output["isOk"] = true;
            }
            catch(Exception ex)
            {
                output["isOk"] = false;
                output["error"] = "General failure.";
                output["generalFailure"] = ex.ToString();
            }

            // jqm access control bits...
            context.Response.AddHeader("Access-Control-Allow-Origin", "*");
            context.Response.AddHeader("Access-Control-Allow-Methods", "POST, GET");

            // send...
            context.Response.ContentType = "text/json";
            context.Response.Write(output.ToString());
        }
开发者ID:mbrit,项目名称:dotnet-streetfoo,代码行数:35,代码来源:AjaxHandler.cs


示例5: DataToMap

 public Map DataToMap(JsonData Data)
 {
     mapname = Data ["Name"].ToString ();
     PerfectMove = int.Parse (Data ["Step"].ToString ());
     width= int.Parse (Data ["Width"].ToString ());
     height= int.Parse (Data ["Height"].ToString ());
     for(int i=0;i<Data["Grid"].Count;i++) {
         JsonData jd=Data["Grid"][i];
         GridPos.Add (new Vector2(float.Parse (jd["x"].ToString ()),float.Parse (jd["y"].ToString ())));
         GridData d=new GridData(int.Parse(jd["data"][0].ToString ()),int.Parse(jd["data"][1].ToString ()),int.Parse(jd["data"][2].ToString ()));
         GData.Add (d);
     }
     for(int i=0;i<Data["Block"].Count;i++)
     {
         JsonData jd=Data["Block"][i];
         if(jd==null)
             break;
         AllBlock.Add (new Vector2(float.Parse (jd["x"].ToString ()),float.Parse (jd["y"].ToString ())));
     }
     GPD = new Dictionary<Vector2, GridData> ();
     for (int i=0; i<GridPos.Count; i++) {
         GPD.Add (GridPos[i],GData[i]);
     }
     return this;
 }
开发者ID:o2yCN,项目名称:Puzzle-Of-Light,代码行数:25,代码来源:Map.cs


示例6: ParseParameters

    protected override void ParseParameters(JsonData parameters)
    {
        base.ParseParameters(parameters);

        MobId = JsonUtilities.ParseInt(parameters, "mob_id");
        KillerCharacterId = JsonUtilities.ParseInt(parameters, "killer_character_id");
    }
开发者ID:ltloibrights,项目名称:AsyncRPG,代码行数:7,代码来源:GameEvent_MobDied.cs


示例7: CheckUser

        public ActionResult CheckUser(ClientUserLoginModel model)
        {
            var re = new JsonData<int>();
            try
            {
                var user = _accountService.GetAllAccounts().FirstOrDefault(u => u.AccountName == model.LoginName);
                if (user != null)
                {
                    var encryptionPassword = _encryption.GetBase64Hash(System.Text.Encoding.UTF8.GetBytes(model.Password.ToCharArray()));
                    if (string.Compare(encryptionPassword, user.Password, false, System.Globalization.CultureInfo.InvariantCulture) == 0)
                    {
                        re.d=user.Id;
                    }
                    else
                        re.m="密码错误!";
                }
                else
                {
                    re.m = "登录名不存在!";
                }

                return Json(re);
            }
            catch (Exception ex)
            {
                Response.StatusCode = 500;
                return Json(ex.Message);
            }
        }
开发者ID:ChuHaiQuan,项目名称:SSO_SITE,代码行数:29,代码来源:ApiController.cs


示例8: Start

    void Start()
    {
        #if UNITY_IPHONE
        //ReportPolicy
        //REALTIME = 0,       //send log when log created
        //BATCH = 1,          //send log when app launch
        //SENDDAILY = 4,      //send log every day's first launch
        //SENDWIFIONLY = 5    //send log when wifi connected

        MobclickAgent.StartWithAppKeyAndReportPolicyAndChannelId("4f3122f152701529bb000042",0,"Develop");
        MobclickAgent.SetAppVersion("1.2.1");
        MobclickAgent.SetLogSendInterval(20);
        JsonData eventAttributes = new JsonData();
        eventAttributes["username"] = "Aladdin";
        eventAttributes["company"] = "Umeng Inc.";

        MobclickAgent.EventWithAttributes("GameState",JsonMapper.ToJson(eventAttributes));
        MobclickAgent.SetLogEnabled(true);
        MobclickAgent.SetCrashReportEnabled(true);
        MobclickAgent.CheckUpdate();
        MobclickAgent.UpdateOnlineConfig();
        MobclickAgent.Event("GameState");
        MobclickAgent.BeginEventWithLabel("New-GameState","identifierID");
        MobclickAgent.EndEventWithLabel("New-GameState","identifierID");
        #elif UNITY_ANDROID
        MobclickAgent.setLogEnabled(true);

        MobclickAgent.onResume();

        // Android: can't call onEvent just before onResume is called, 'can't call onEvent before session is initialized' will be print in eclipse logcat
        // Android: call MobclickAgent.onPause(); when Application exit.
        #endif
    }
开发者ID:Waigo21,项目名称:GamePrototypes,代码行数:33,代码来源:MobclickAgent.cs


示例9: LevelData

 LevelData(JsonData _item)
 {
     try
     {
         JsonData item = _item;
         foreach (string key in item.Keys)
         {
             switch (key)
             {
                 case "Level":
                     Level = int.Parse(item[key].ToString());
                     break;
                 case "NeedExp":
                     NeedExp = int.Parse(item[key].ToString());
                     break;
                 case "Point":
                     Point = int.Parse(item[key].ToString());
                     break;
                 default:
                     Debug.LogWarning(string.Format("Level表有不明屬性:{0}", key));
                     break;
             }
         }
     }
     catch (Exception ex)
     {
         Debug.LogException(ex);
     }
 }
开发者ID:scozirge,项目名称:AVentureCapital,代码行数:29,代码来源:LevelData.cs


示例10: TestGetReportsByUser

        public void TestGetReportsByUser()
        {
            ResetReports();

            // create some reports..
            User user = this.Creator.CreateUser();
            Report report1 = this.Creator.CreateReport(user);
            Report report2 = this.Creator.CreateReport(user);
            Report report3 = this.Creator.CreateReport(user);
            Report report4 = this.Creator.CreateReport(user);
            Report report5 = this.Creator.CreateReport(user);

            // get...
            HandleGetReportsByUser handler = new HandleGetReportsByUser();
            JsonData output = new JsonData();
            handler.DoRequest(this.CreateJsonData(user), output);

            // check...
            string asString = output.GetValueSafe<string>("reports");
            IList reports = (IList)new JavaScriptSerializer().DeserializeObject(asString);
            Assert.AreEqual(5, reports.Count);

            // check...
            Assert.AreEqual(this.ApiKey, ((IDictionary)reports[0])["apiKey"]);
            Assert.AreEqual(user.IdAsString, ((IDictionary)reports[0])["ownerUserId"]);
            Assert.AreEqual(this.ApiKey, ((IDictionary)reports[1])["apiKey"]);
            Assert.AreEqual(user.IdAsString, ((IDictionary)reports[1])["ownerUserId"]);
            Assert.AreEqual(this.ApiKey, ((IDictionary)reports[2])["apiKey"]);
            Assert.AreEqual(user.IdAsString, ((IDictionary)reports[2])["ownerUserId"]);
            Assert.AreEqual(this.ApiKey, ((IDictionary)reports[3])["apiKey"]);
            Assert.AreEqual(user.IdAsString, ((IDictionary)reports[3])["ownerUserId"]);
            Assert.AreEqual(this.ApiKey, ((IDictionary)reports[4])["apiKey"]);
            Assert.AreEqual(user.IdAsString, ((IDictionary)reports[4])["ownerUserId"]);
        }
开发者ID:mbrit,项目名称:dotnet-streetfoo,代码行数:34,代码来源:ReportTests.cs


示例11: LoopChildren

	/// <summary>
	/// Loops the children.
	/// </summary>
	/// <returns>The children.</returns>
	/// <param name="t">T.</param>
	private static JsonData LoopChildren(Transform t)
	{
		RectTransform rt = (RectTransform)t;

		JsonData jd = new JsonData ();
		jd ["name"] = t.name;
		JsonData trJD = new JsonData ();
		trJD ["position"] = rt.anchoredPosition.VectorToJson ();
		trJD ["sizeDelta"] = rt.sizeDelta.VectorToJson ();
		trJD ["anchorMin"] = rt.anchorMin.VectorToJson ();
		trJD ["anchorMax"] = rt.anchorMax.VectorToJson ();
		trJD ["pivot"] = rt.pivot.VectorToJson ();
		trJD ["rotation"] = rt.rotation.eulerAngles.VectorToJson ();
		trJD ["scale"] = rt.localScale.VectorToJson ();
		jd ["transform"] = trJD;

		int len = t.childCount;
		JsonData ch = new JsonData ();
		for (int i = 0; i < len; ++i) {
			ch.Add(LoopChildren (t.GetChild (i)));
		}
		string jsStr = JsonMapper.ToJson (ch);
		jd ["children"] = string.IsNullOrEmpty(jsStr)?"[]":ch;

		return jd;
	}
开发者ID:liuhanxu,项目名称:LHJ,代码行数:31,代码来源:_UITools.cs


示例12: MachineInfo

 public MachineInfo(JsonData data)
 {
     ParseSlots(data["slots"]);
     ParseReels((IList)data["reels"]);
     ParseLines((IList)data["lines"]);
     ParsePayouts((IList)data["payouts"]);
 }
开发者ID:Jarisha,项目名称:Social-Slots,代码行数:7,代码来源:MachineInfo.cs


示例13: CreateJoinMsgJson

    public static JsonData CreateJoinMsgJson()
    {
        JsonData ret = new JsonData (JsonType.Object);
        ret ["msg_type"] = MSG_R_ClientJoinWithConfig;
        JsonData config = new JsonData (JsonType.Object);
        config["environment_scene"] = "ProceduralGeneration";
        config["random_seed"] = 1; // Omit and it will just choose one at random. Chosen seeds are output into the log(under warning or log level)."should_use_standardized_size": False,
        config["standardized_size"] =  new Vector3(1.0f, 1.0f, 1.0f).ToJson();
        config["disabled_items"] = new JsonData(JsonType.Array); //["SQUIRL", "SNAIL", "STEGOSRS"], // A list of item names to not use, e.g. ["lamp", "bed"] would exclude files with the word "lamp" or "bed" in their file path
        config["permitted_items"] = new JsonData(JsonType.Array); //["bed1", "sofa_blue", "lamp"],
        config["complexity"] = 7500;
        config["num_ceiling_lights"] = 4;
        config["minimum_stacking_base_objects"] = 15;
        config["minimum_objects_to_stack"] = 100;
        config["room_width"] = 40.0f;
        config["room_height"] = 15.0f;
        config["room_length"] = 40.0f;
        config["wall_width"] = 1.0f;
        config["door_width"] = 1.5f;
        config["door_height"] = 3.0f;
        config["window_size_width"] = 5.0f;
        config["window_size_height"] = 5.0f;
        config["window_placement_height"] = 5.0f;
        config["window_spacing"] = 10.0f;  // Average spacing between windows on walls
        config["wall_trim_height"] = 0.5f;
        config["wall_trim_thickness"] = 0.01f;
        config["min_hallway_width"] = 5.0f;
        config["number_rooms"] = 1;
        config["max_wall_twists"] = 3;
        config["max_placement_attempts"] = 300;   // Maximum number of failed placements before we consider a room fully filled.
        config["grid_size"] = 0.4f;    // Determines how fine tuned a grid the objects are placed on during Proc. Gen. Smaller the number, the

        ret["config"] = config;
        return ret;
    }
开发者ID:dicarlolab,项目名称:ThreeDWorld,代码行数:35,代码来源:NetMessenger.cs


示例14: UICall

 public object UICall(JsonData data)
 {
     string name = data["name"].ToString();
     string method = data["method"].ToString();
     JsonData arg_data = data["args"];
     object[] args = new object[arg_data.Count];
     for (int i = 0; i < arg_data.Count; i++)
     {
         JsonData d = arg_data[i];
         if (d.IsString) { args[i] = (string)d; continue; }
         if (d.IsBoolean) { args[i] = (bool)d; continue; }
         if (d.IsDouble) { args[i] = (double)d; continue; }
         if (d.IsInt) { args[i] = (int)d; continue; }
         if (d.IsLong) { args[i] = (long)d; continue; }
         if (d.IsArray) { args[i] = d; continue; }
         if (d.IsObject) { args[i] = d; continue; }
     }
     Component ui = UIManager.instance.Find(name);
     if (ui == null)
     {
         Debug.LogError("UICall: can not find the ui:" + name);
         return null;
     }
     try
     {
         object result = Type.GetType(name).InvokeMember(method, BindingFlags.InvokeMethod, null, ui, args);
         if (result != null) return result;
     }
     catch (Exception ex)
     {
         Debug.LogError("UICall is error:" + method + ex.Message);
     }
     return null;
 }
开发者ID:sundoom,项目名称:nova,代码行数:34,代码来源:GameInterface.cs


示例15: OnDownloadComplete

    private void OnDownloadComplete(string worksheetName, JsonData[] data, string error)
    {
        if (m_WorksheetName == worksheetName)
        {
            if (!string.IsNullOrEmpty(error))
            {
                if (m_ProgressImage != null)
                {
                    m_ProgressImage.fillAmount = 0;
                }

                if (m_ProgressText != null)
                {
                    m_ProgressText.text = "ERROR";
                }
                Debug.Log("Download error on: " + m_WorksheetName + " - " + error);
            }
            else
            {
                if (m_ProgressImage != null)
                {
                    m_ProgressImage.fillAmount = 1;
                }

                if (m_ProgressText != null)
                {
                    m_ProgressText.text = 100.ToString("00.00");
                }
                Debug.Log("Download complete on: " + m_WorksheetName + " - " + JsonMapper.ToJson(data));
            }
        }
    }
开发者ID:starvoxel,项目名称:sw_d20,代码行数:32,代码来源:DataFetchTester.cs


示例16: AjaxContext

        internal AjaxContext(JsonData input)
        {
            // get the api out...
            string apiKey = input.GetValueSafe<string>("apiKey");
            if (string.IsNullOrEmpty(apiKey))
                throw new InvalidOperationException("The 'apiKey' value was not specified in the request.");
            this.ApiUser = ApiUser.GetOrCreateApiUser(new Guid(apiKey));
            if(ApiUser == null)
                throw new InvalidOperationException("'ApiUser' is null.");

            // do we have a logon token?
            string asString = input.GetValueSafe<string>("logonToken");
            if (!(string.IsNullOrEmpty(asString)))
            {
                Token token = Token.GetByToken(this.ApiUser, asString);
                if (token == null)
                    throw new InvalidOperationException(string.Format("A token with ID '{0}' was not found.", asString));

                // update...
                token.UpdateExpiration();

                // set...
                this.Token = token;
            }
        }
开发者ID:mbrit,项目名称:dotnet-streetfoo,代码行数:25,代码来源:AjaxContext.cs


示例17: SpriteData

 SpriteData(JsonData _item)
 {
     try
     {
         JsonData item = _item;
         foreach (string key in item.Keys)
         {
             switch (key)
             {
                 case "Name":
                     Name = item[key].ToString();
                     break;
                 case "Path":
                     Path = item[key].ToString();
                     break;
                 default:
                     Debug.LogWarning(string.Format("Sprite表有不明屬性:{0}", key));
                     break;
             }
         }
         SetSprite();
     }
     catch (Exception ex)
     {
         Debug.LogException(ex);
     }
 }
开发者ID:scozirge,项目名称:AVentureCapital,代码行数:27,代码来源:SpriteData.cs


示例18: AppendParameters

    protected override void AppendParameters(JsonData parameters)
    {
        base.AppendParameters(parameters);

        parameters["mob_id"] = MobId;
        parameters["killer_character_id"] = KillerCharacterId;
    }
开发者ID:ltloibrights,项目名称:AsyncRPG,代码行数:7,代码来源:GameEvent_MobDied.cs


示例19: Player

 //{"type":"auth_response","player":{"_username":"ryan","_xp":0,"_credits":500,"_level":1}}
 public Player(JsonData jo)
 {
     m_user = (string)jo["_username"];
     m_xp = (int)jo["_xp"];
     m_credits = (int)jo["_credits"];
     m_level = (int)jo["_level"];
 }
开发者ID:Jarisha,项目名称:Social-Slots,代码行数:8,代码来源:Player.cs


示例20: SortAndSend

    public void SortAndSend(JsonData[] ssObjects)
    {
        OptionalMiddleStruct container = new OptionalMiddleStruct();
        //int score = 0;

        // Break apart data and test it against current score
        for (int i = 0; i < ssObjects.Length; i++)
        {
            container.place = ssObjects[i]["place"].ToString();
            container.name = ssObjects[i]["name"].ToString();
            container.score = int.Parse(ssObjects[i]["score"].ToString());

            //Debug.Log("Checking.........");
            // if current score is higher than 
            if (EndlessPlayerController.Score >= container.score)
            {
                container.score = EndlessPlayerController.Score;
               // Debug.Log("You've beaten a global high score!");

                _PanelToDeactivate = GameObject.FindGameObjectWithTag("HUDPanel");
                _PanelToDeactivate.SetActive(false);
                _UniversalScorePanel.SetActive(true);
                containerToSend = container; // add to external container in preparation to send
                
                EndlessGameInfo._AllowGlobalHighScore = true;
                break;
            }                
        }        
    }
开发者ID:Soverance,项目名称:EndlessReach,代码行数:29,代码来源:RefreshLeaderboard.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# JsonDeserializer类代码示例发布时间:2022-05-24
下一篇:
C# JsonConverter类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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