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

C# Json.JsonObject类代码示例

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

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



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

示例1: ReciveData

 public void ReciveData(JsonObject reciveData)
 {
     this.reciveData = reciveData;
     if (reciveData["command"] == "areaData") {
         UpdateMap(reciveData["areaDatas"]);
     }
 }
开发者ID:Sweetwater,项目名称:NetworkGame,代码行数:7,代码来源:GameScene.cs


示例2: Save

		/// <summary>
		/// 設定を保存します
		/// </summary>
		public async Task Save()
		{
			await Task.Run(() =>
			{
				// Serialize
				var json = new JsonObject();
				JsonPrimitive element;

				JsonPrimitive.TryCreate(Account.BaseUrl, out element);
				json.Add("BaseUrl", element);

				JsonPrimitive.TryCreate(Account.UserKey, out element);
				json.Add("UserKey", element);

				JsonPrimitive.TryCreate(PostTextFormat, out element);
				json.Add("PostTextFormat", element);

				JsonPrimitive.TryCreate((int)TargetPlayer, out element);
				json.Add("TargetPlayer", element);

				JsonPrimitive.TryCreate(IsAutoPost, out element);
				json.Add("IsAutoPost", element);

				JsonPrimitive.TryCreate(AutoPostInterval, out element);
				json.Add("AutoPostInterval", element);

				// Save
				using (var sw = new System.IO.StreamWriter("setting.json"))
				{
					json.Save(sw);
				}
			});
		}
开发者ID:marihachi,项目名称:MisskeyNowPlaying,代码行数:36,代码来源:SettingStorage.cs


示例3: FromJson

        /// <summary>${iServerJava6R_GeometryOverlayAnalystResult_method_fromJson_D}</summary>
        /// <returns>${iServerJava6R_GeometryOverlayAnalystResult_method_fromJson_return}</returns>
        /// <param name="jsonResult">${iServerJava6R_GeometryOverlayAnalystResult_method_fromJson_param_jsonObject }</param>
        public static GeometryOverlayAnalystResult FromJson(JsonObject jsonResult)
        {
            GeometryOverlayAnalystResult result = new GeometryOverlayAnalystResult();
            result.ResultGeometry = (ServerGeometry.FromJson(jsonResult)).ToGeometry();

            return result;
        }
开发者ID:SuperMap,项目名称:iClient-for-Silverlight,代码行数:10,代码来源:GeometryOverlayAnalystResult.cs


示例4: FromJson

 /// <summary>${IS6_ServerGeometry_method_FromJson_D}</summary>
 /// <param name="jsonObject">${IS6_ServerGeometry_method_FromJson_param_jsonObject}</param>
 /// <returns>${IS6_ServerGeometry_method_FromJson_return}</returns>
 public static ServerGeometry FromJson(JsonObject jsonObject)
 {
     if (jsonObject == null)
     {
         return null;
     }
     ServerGeometry geometry = new ServerGeometry();
     geometry.Feature = (ServerFeatureType)(int)jsonObject["feature"];
     geometry.ID = (int)jsonObject["id"];
     JsonArray parts = (JsonArray)jsonObject["parts"];
     if (parts != null && parts.Count > 0)
     {
         geometry.Parts = new List<int>();
         for (int i = 0; i < parts.Count; i++)
         {
             geometry.Parts.Add((int)parts[i]);
         }
     }
     JsonArray point2Ds = (JsonArray)jsonObject["points"];
     if (point2Ds != null && point2Ds.Count > 0)
     {
         geometry.Point2Ds = new Point2DCollection();
         for (int i = 0; i < point2Ds.Count; i++)
         {
             geometry.Point2Ds.Add(JsonHelper.ToPoint2D((JsonObject)point2Ds[i]));
         }
     }
     return geometry;
 }
开发者ID:SuperMap,项目名称:iClient-for-Silverlight,代码行数:32,代码来源:ServerGeometry.cs


示例5: Call

        protected JsonObject Call(string subpath, string method = "GET",  string contentType = "application/text",
            string data = "")
        {
            string uri;

            uri = String.Format("https://{0}{1}", _options["api_base"],
                                    GetPath(subpath));

            if(_sessionId != null && _sessionId != "")
            {
                uri = String.Format("{0}{1}", uri, String.Format("&hs={0}", _sessionId));
            }

            Debug.WriteLine(uri);
            var returnVal = UserWebClient.UploadString(uri, method: method, contentType: contentType, data: data);

            if (returnVal != null)
            {
                if (returnVal.Length > 0)
                {
                    JsonObject o = new JsonObject(JsonValue.Parse(returnVal));
                    if (SuccessfulCall(o))
                    {
                        return o;
                    }
                    else
                    {
                        var response = JsonConvert.DeserializeObject<Helpers.APIResponse>(o.ToString());
                        throw new Exception(String.Format("Unsuccessful call to web api. {0}", response.result.code), new Exception(String.Format("{0}", response.result.description)));
                    }
                }
            }

            return new JsonObject();
        }
开发者ID:cal5fishbowl,项目名称:ISLSharp,代码行数:35,代码来源:BaseClass.cs


示例6: PostEntry

 public void PostEntry()
 {
     var json = new JsonObject();
     json["command"] = "entry";
     var send = "data=" + json.ToString();
     network.SendPostRequest(send);
 }
开发者ID:Sweetwater,项目名称:NetworkGame,代码行数:7,代码来源:NetworkController.cs


示例7: Delete

 public void Delete(JsonObject input)
 {
     using (_profiler.Step("DeploymentService.Delete"))
     {
         _deploymentManager.Delete((string)input["id"]);
     }
 }
开发者ID:piscisaureus,项目名称:kudu,代码行数:7,代码来源:DeploymentService.cs


示例8: FromJson

        //方法
        /// <summary>${iServer2_GetMapStatusResult_method_FromJson_D}</summary>
        /// <param name="jsonObject">${iServer2_GetMapStatusResult_method_FromJson_param_jsonObject}</param>
        /// <returns>${iServer2_GetMapStatusResult_method_FromJson_return}</returns>
        public static GetMapStatusResult FromJson(JsonObject jsonObject)
        {
            if (jsonObject == null)
            {
                return null;
            }

            GetMapStatusResult result = new GetMapStatusResult();

            #region
            result.MapName = (string)jsonObject["mapName"];
            result.MapBounds = ToRectangle2D((JsonObject)jsonObject["mapBounds"]);
            result.ReferViewBounds = ToRectangle2D((JsonObject)jsonObject["referViewBounds"]);
            result.ReferViewer = ToRect((JsonObject)jsonObject["referViewer"]);
            result.ReferScale = (double)jsonObject["referScale"];
            result.CRS = ToCRS((JsonObject)jsonObject["coordsSys"]);
            #endregion
            if (jsonObject["layers"] != null && jsonObject["layers"].Count > 0)
            {
                result.ServerLayers = new List<ServerLayer>();
                for (int i = 0; i < jsonObject["layers"].Count; i++)
                {
                    result.ServerLayers.Add(ServerLayer.FromJson((JsonObject)jsonObject["layers"][i]));
                }
            }

            return result;
        }
开发者ID:SuperMap,项目名称:iClient-for-Silverlight,代码行数:32,代码来源:GetMapStatusResult.cs


示例9: CustomRootElement

 public CustomRootElement(string title, JsonObject data)
     : base(title)
 {
     this.data = data;
     apiNode = DrupalApiParser.FromJsonObject(data);
     //apiNode = ApiNode.
 }
开发者ID:josiahpeters,项目名称:CCBoise,代码行数:7,代码来源:CustomRootElement.cs


示例10: Parse

        internal static JsonObject Parse(IEnumerable<Tuple<string, string>> nameValuePairs, int maxDepth)
        {
            JsonObject result = new JsonObject();
            foreach (var nameValuePair in nameValuePairs)
            {
                if (nameValuePair.Item1 == null)
                {
                    if (string.IsNullOrEmpty(nameValuePair.Item2))
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                            new ArgumentException(DiagnosticUtility.GetString(SR.QueryStringNameShouldNotNull), "nameValuePairs"));
                    }

                    string[] path = new string[] { nameValuePair.Item2 };
                    Insert(result, path, null);
                }
                else
                {
                    string[] path = GetPath(nameValuePair.Item1, maxDepth);
                    Insert(result, path, nameValuePair.Item2);
                }
            }

            FixContiguousArrays(result);
            return result;
        }
开发者ID:nuxleus,项目名称:WCFWeb,代码行数:26,代码来源:FormUrlEncodedExtensions.cs


示例11: FromJson

        /// <summary>${iServerJava6R_DatasetInfo_method_FromJson_D}</summary>
        /// <returns>${iServerJava6R_DatasetInfo_method_FromJson_return}</returns>
        /// <param name="jsonObject">${iServerJava6R_DatasetInfo_method_FromJson_param_jsonObject}</param>
        public static DatasetInfo FromJson(JsonObject jsonObject)
        {
            if (jsonObject == null)
            {
                return null;
            }
            DatasetInfo result = new DatasetInfo();
            result.Name = (string)jsonObject["name"];

            if (jsonObject["type"] != null)
            {
                result.Type = (DatasetType)Enum.Parse(typeof(DatasetType), (string)jsonObject["type"], true);
            }
            else
            {
            }
            result.DatasourceName = (string)jsonObject["dataSourceName"];
            if (jsonObject["bounds"] != null)
            {
                result.Bounds = DatasetInfo.ToRectangle2D((JsonObject)jsonObject["bounds"]);
            }
            else
            {  }
            return result;
        }
开发者ID:SuperMap,项目名称:iClient-for-Silverlight,代码行数:28,代码来源:DatasetInfo.cs


示例12: Add

 public static void Add(this MultipartFormDataContent source, JsonObject json)
 {
     foreach(var kv in json)
     {
         source.Add(kv);
     };
 }
开发者ID:CVertex,项目名称:bigml-csharp,代码行数:7,代码来源:JsonContent.cs


示例13: AddRangeParamsTest

        public void AddRangeParamsTest()
        {
            string key1 = AnyInstance.AnyString;
            string key2 = AnyInstance.AnyString2;
            JsonValue value1 = AnyInstance.AnyJsonValue1;
            JsonValue value2 = AnyInstance.AnyJsonValue2;

            List<KeyValuePair<string, JsonValue>> items = new List<KeyValuePair<string, JsonValue>>()
            {
                new KeyValuePair<string, JsonValue>(key1, value1),
                new KeyValuePair<string, JsonValue>(key2, value2),
            };

            JsonObject target;

            target = new JsonObject();
            target.AddRange(items[0], items[1]);
            Assert.AreEqual(2, target.Count);
            ValidateJsonObjectItems(target, key1, value1, key2, value2);

            target = new JsonObject();
            target.AddRange(items.ToArray());
            Assert.AreEqual(2, target.Count);
            ValidateJsonObjectItems(target, key1, value1, key2, value2);

            ExceptionTestHelper.ExpectException<ArgumentNullException>(delegate { new JsonObject().AddRange((KeyValuePair<string, JsonValue>[])null); });
            ExceptionTestHelper.ExpectException<ArgumentNullException>(delegate { new JsonObject().AddRange((IEnumerable<KeyValuePair<string, JsonValue>>)null); });

            items[1] = new KeyValuePair<string, JsonValue>(key2, AnyInstance.DefaultJsonValue);
            ExceptionTestHelper.ExpectException<ArgumentException>(delegate { new JsonObject().AddRange(items.ToArray()); });
            ExceptionTestHelper.ExpectException<ArgumentException>(delegate { new JsonObject().AddRange(items[0], items[1]); });
        }
开发者ID:nuxleus,项目名称:WCFWeb,代码行数:32,代码来源:JsonObjectTest.cs


示例14: FromJson

        /// <summary>${iServerJava6R_FindLocationAnalystResult_method_fromJson_D}</summary>
        /// <returns>${iServerJava6R_FindLocationAnalystResult_method_fromJson_Return}</returns>
        /// <param name="json">${iServerJava6R_FindLocationAnalystResult_method_fromJson_param_jsonObject}</param>
        public static FindLocationAnalystResult FromJson(JsonObject json)
        {
            if (json == null)
                return null;

            FindLocationAnalystResult result = new FindLocationAnalystResult();
            //result.MapImage = NAResultMapImage.FromJson((JsonObject)json["mapImage"]);

            if (json["demandResults"] != null && json["demandResults"].Count > 0)
            {
                result.DemandResults = new List<DemandResult>();
                for (int i = 0; i < json["demandResults"].Count; i++)
                {
                    result.DemandResults.Add(DemandResult.FromJson((JsonObject)json["demandResults"][i]));
                }
            }
            if (json["supplyResults"] != null && json["supplyResults"].Count > 0)
            {
                result.SupplyResults = new List<SupplyResult>();
                for (int i = 0; i < json["supplyResults"].Count; i++)
                {
                    result.SupplyResults.Add(SupplyResult.FromJson((JsonObject)json["supplyResults"][i]));
                }
            }

            return result;
        }
开发者ID:SuperMap,项目名称:iClient-for-Silverlight,代码行数:30,代码来源:FindLocationAnalystResult.cs


示例15: JsonObj

        static JsonObject JsonObj(PushNotification notification)
        {
            var jsonObj = new JsonObject();

            jsonObj["aps"] = JsonObject(notification.Payload);
            if (notification.DeviceTokens != null)
            {
                jsonObj["device_tokens"] = notification.DeviceTokens.ToJsonArray();
            }
            if (notification.Aliases != null)
            {
                jsonObj["aliases"] = notification.Aliases.ToJsonArray();
            }
            if (notification.Tags != null)
            {
                jsonObj["tags"] = notification.Tags.ToJsonArray();
            }
            if (notification.ExcludeTokens != null)
            {
                jsonObj["exclude_tokens"] = notification.ExcludeTokens.ToJsonArray();
            }

            if (notification.CustomData != null)
            {
                foreach (var pair in notification.CustomData)
                {
                    ValidateKey(pair.Key);
                    jsonObj[pair.Key] = pair.Value;
                }
            }

            return jsonObj;
        }
开发者ID:farhadbheekoo,项目名称:UrbanBlimp,代码行数:33,代码来源:BatchPushRequestSerializer.cs


示例16: FromJson

        /// <summary>${iServer2_DataTable_method_FromJson_D}</summary>
        /// <param name="jsonObject">${iServer2_DataTable_method_FromJson_param_jsonObject}</param>
        /// <returns>${iServer2_DataTable_method_FromJson_return}</returns>
        public static DataTable FromJson(JsonObject jsonObject)
        {
            if (jsonObject == null)
            {
                return null;
            }
            DataTable dt = new DataTable();

            JsonArray columnsInJson = (JsonArray)jsonObject["columns"];
            if (columnsInJson != null && columnsInJson.Count > 0)
            {
                dt.Columns = new List<DataColumn>();
                for (int i = 0; i < columnsInJson.Count; i++)
                {
                    dt.Columns.Add(DataColumn.FromJson((JsonObject)columnsInJson[i]));
                }
            }
            JsonArray rowsInJson = (JsonArray)jsonObject["rows"];
            if (rowsInJson != null && rowsInJson.Count > 0)
            {
                dt.Rows = new List<DataRow>();
                for (int i = 0; i < rowsInJson.Count; i++)
                {
                    dt.Rows.Add(DataRow.FromJson((JsonObject)rowsInJson[i]));
                }
            }

            return dt;
        }
开发者ID:SuperMap,项目名称:iClient-for-Silverlight,代码行数:32,代码来源:DataTable.cs


示例17: FromJson

        internal static LabelMixedTextStyle FromJson(JsonObject json)
        {
            if (json == null) return null;
            LabelMixedTextStyle textStyle = new LabelMixedTextStyle();
            textStyle.DefaultStyle = ServerTextStyle.FromJson((JsonObject)json["defaultStyle"]);
            textStyle.Separator = (string)json["separator"];
            textStyle.SeparatorEnabled = (bool)json["separatorEnabled"];

            if ((JsonArray)json["splitIndexes"] != null && ((JsonArray)json["splitIndexes"]).Count > 0)
            {
                List<int> list = new List<int>();
                foreach (int item in (JsonArray)json["splitIndexes"])
                {
                    list.Add(item);
                }
                textStyle.SplitIndexes = list;
            }

            if (json["styles"] != null)
            {
                List<ServerTextStyle> textStyleList = new List<ServerTextStyle>();
                foreach (JsonObject item in (JsonArray)json["styles"])
                {
                    textStyleList.Add(ServerTextStyle.FromJson(item));
                }
                textStyle.Styles = textStyleList;
            }

            return textStyle;
        }
开发者ID:SuperMap,项目名称:iClient-for-Silverlight,代码行数:30,代码来源:LabelMixedTextStyle.cs


示例18: FromJson

        /// <summary>${iServer2_ResultSet_method_FromJson_D}</summary>
        /// <returns>${iServer2_ResultSet_method_FromJson_return}</returns>
        /// <param name="jsonObject">${iServer2_ResultSet_method_FromJson_param_jsonObject}</param>
        public static ResultSet FromJson(JsonObject jsonObject)
        {
            if (jsonObject == null)
            {
                return null;
            }

            ResultSet resultSet = new ResultSet();
            resultSet.TotalCount = (int)jsonObject["totalCount"];
            if (resultSet.TotalCount == 0)
            {
                return null;
            }//如果为0,认为结果为空?
            resultSet.CurrentCount = (int)jsonObject["currentCount"];
            resultSet.CustomResponse = (string)jsonObject["customResponse"];

            JsonArray recordSets = (JsonArray)jsonObject["recordSets"];
            if (recordSets != null && recordSets.Count > 0)
            {
                resultSet.RecordSets = new List<RecordSet>();
                for (int i = 0; i < recordSets.Count; i++)
                {
                    resultSet.RecordSets.Add(RecordSet.FromJson((JsonObject)recordSets[i]));
                }
            }
            return resultSet;
        }
开发者ID:SuperMap,项目名称:iClient-for-Silverlight,代码行数:30,代码来源:ResultSet.cs


示例19: Build

 public void Build(JsonObject input)
 {
     using (_profiler.Step("DeploymentService.Build"))
     {
         _deploymentManager.Deploy((string)input["id"]);
     }
 }
开发者ID:piscisaureus,项目名称:kudu,代码行数:7,代码来源:DeploymentService.cs


示例20: Run

 public static void Run()
 {
     var config = new HttpConfiguration();
     config.RequestHandlers += (coll, ep, desc) =>
                                  {
                                      if (
                                          desc.Attributes.Any(a => a.GetType() == typeof(JsonExtractAttribute))
                                          )
                                      {
                                          coll.Add(new JsonExtractHandler(desc));    
                                      }
                                  };
     using (var sh = new HttpServiceHost(typeof(TheService), config, "http://localhost:8080"))
     {
         sh.Open();
         Console.WriteLine("host is opened");
         var client = new HttpClient();
         dynamic data = new JsonObject();
         data.x = "a string";
         data.y = "13";
         data.z = "3.14";
         var resp = client.PostAsync("http://localhost:8080/v2", new ObjectContent<JsonValue>(data, "application/json")).Result;
         Console.WriteLine(resp.StatusCode);
     }
 }
开发者ID:pmhsfelix,项目名称:WcfWebApi.Preview5.Explorations,代码行数:25,代码来源:JsonValueDemo.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Json.JsonValue类代码示例发布时间:2022-05-26
下一篇:
C# Tokens.X509SecurityToken类代码示例发布时间: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