本文整理汇总了C#中Jayrock.Json.JsonObject.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# JsonObject.Contains方法的具体用法?C# JsonObject.Contains怎么用?C# JsonObject.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jayrock.Json.JsonObject
的用法示例。
在下文中一共展示了JsonObject.Contains方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ContainsNonExistingViaGenericCollection
public void ContainsNonExistingViaGenericCollection()
{
ICollection<KeyValuePair<string, object>> obj = new JsonObject();
obj.Add(new KeyValuePair<string, object>("first", 123));
Assert.IsFalse(obj.Contains(new KeyValuePair<string, object>("second", 456)));
}
示例2: BuildHolder
/**
* Parse the steps in the path into JSON Objects.
*/
static JsonObject BuildHolder(JsonObject root, String[] steps, int currentStep)
{
if (currentStep > steps.Length - 2)
{
return root;
}
Match matcher = ARRAY_MATCH.Match(steps[currentStep]);
if (matcher.Success)
{
// Handle as array
String fieldName = matcher.Groups[1].Value;
int index = int.Parse(matcher.Groups[2].Value);
JsonArray newArrayStep;
if (root.Contains(fieldName))
{
newArrayStep = root[fieldName] as JsonArray;
}
else
{
newArrayStep = new JsonArray();
root.Put(fieldName, newArrayStep);
}
JsonObject newStep = new JsonObject();
newArrayStep[index] = newStep;
return BuildHolder(newStep, steps, ++currentStep);
}
else
{
JsonObject newStep;
if (root.Contains(steps[currentStep]))
{
newStep = root[steps[currentStep]] as JsonObject;
}
else
{
newStep = new JsonObject();
root.Put(steps[currentStep], newStep);
}
return BuildHolder(newStep, steps, ++currentStep);
}
}
示例3: getModuleId
/**
* @param json
* @return module id from the request, or null if not present
* @throws JSONException
*/
private static string getModuleId(JsonObject json)
{
if (json.Contains("moduleId"))
{
return json["moduleId"].ToString();
}
return null;
}
示例4: ServerListItem
/// <summary>
/// Create an item from json code
/// </summary>
/// <param name="jsonObject">the json object to parse</param>
public ServerListItem(JsonObject jsonObject)
{
if (jsonObject.Contains("name")) Name = jsonObject["name"].ToString();
if (jsonObject.Contains("ip")) Ip = jsonObject["ip"].ToString();
if (jsonObject.Contains("uuid")) Uuid = jsonObject["uuid"].ToString();
if (jsonObject.Contains("level")) OpLevel = int.Parse(jsonObject["level"].ToString());
if (jsonObject.Contains("created")) Created = jsonObject["created"].ToString();
if (jsonObject.Contains("source")) Source = jsonObject["source"].ToString();
if (jsonObject.Contains("expires")) Expires = jsonObject["expires"].ToString();
if (jsonObject.Contains("reason")) Reason = jsonObject["reason"].ToString();
}
示例5: getArrayItem
public static string getArrayItem(JsonObject ob, string arrayname, int arrayind)
{
if (ob == null || !ob.Contains(arrayname)) return "";
if (!(ob[arrayname] is JsonArray)) return "";
JsonArray arr = (JsonArray)ob[arrayname];
if (arr.Length < arrayind) return "";
return Converter.toString(arr[arrayind]);
}
示例6: dispatch
private void dispatch(JsonObject request, HttpResponse servletResponse, ISecurityToken token)
{
String key = null;
if (request.Contains("id"))
{
key = request["id"] as String;
}
RpcRequestItem requestItem = new RpcRequestItem(request, token, jsonConverter);
// Resolve each Future into a response.
// TODO: should use shared deadline across each request
ResponseItem response = getResponseItem(HandleRequestItem(requestItem));
Object result = getJsonResponse(key, response, requestItem);
servletResponse.Output.Write(jsonConverter.ConvertToString(result));
}
示例7: getEntryObject
/**
* Inspects the passed object for one of several specific properties and, if
* found, returns that property as a JsonObject object. All valid response
* objects which encapsulate a single data item (e.g. a person) must have
* this property.
*
* @param root JsonObject to query for the presence of the specific property
* @throws OpenSocialRequestException if property is not found _in the passed
* object
* @throws JSONException
*/
private static JsonObject getEntryObject(JsonObject root)
{
JsonObject entry = new JsonObject();
if (root.Contains("data")) {
entry = root.getJSONObject("data");
} else if (root.Contains("entry")) {
entry = root.getJSONObject("entry");
} else {
throw new OpenSocialRequestException("Entry not found");
}
return entry;
}
示例8: getEntryArray
/**
* Inspects the passed object for one of several specific properties and, if
* found, returns that property as a JsonArray object. All valid response
* objects which contain a data collection (e.g. a collection of people)
* must have this property.
*
* @param root JsonObject to query for the presence of the specific property
* @throws OpenSocialRequestException if property is not found _in the passed
* object
* @throws JSONException
*/
private static JsonArray getEntryArray(JsonObject root)
{
JsonArray entry = new JsonArray();
if (root.Contains("entry")) {
entry = (JsonArray)root["entry"];
} else if (root.Contains("data")) {
entry = (JsonArray)root.getJSONObject("data")["list"];
} else {
throw new OpenSocialRequestException("Entry not found");
}
return entry;
}