本文整理汇总了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"]);
}
}
示例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);
}
});
}
示例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;
}
示例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;
}
示例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();
}
示例6: PostEntry
public void PostEntry()
{
var json = new JsonObject();
json["command"] = "entry";
var send = "data=" + json.ToString();
network.SendPostRequest(send);
}
示例7: Delete
public void Delete(JsonObject input)
{
using (_profiler.Step("DeploymentService.Delete"))
{
_deploymentManager.Delete((string)input["id"]);
}
}
示例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;
}
示例9: CustomRootElement
public CustomRootElement(string title, JsonObject data)
: base(title)
{
this.data = data;
apiNode = DrupalApiParser.FromJsonObject(data);
//apiNode = ApiNode.
}
示例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;
}
示例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;
}
示例12: Add
public static void Add(this MultipartFormDataContent source, JsonObject json)
{
foreach(var kv in json)
{
source.Add(kv);
};
}
示例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]); });
}
示例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;
}
示例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;
}