当前位置: 首页>>代码示例>>C#>>正文


C# Json.JsonObject类代码示例

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


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


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