本文整理汇总了C#中Jayrock.Json.JsonArray.GetObject方法的典型用法代码示例。如果您正苦于以下问题:C# JsonArray.GetObject方法的具体用法?C# JsonArray.GetObject怎么用?C# JsonArray.GetObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jayrock.Json.JsonArray
的用法示例。
在下文中一共展示了JsonArray.GetObject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getResponse
/**
* Parses the passed JSON string into an OpenSocialResponse object -- if the
* passed string represents a JSON array, each object _in the array is added
* to the returned object keyed on its "id" property.
*
* @param _in The complete JSON string returned from an OpenSocial container
* _in response to a request for data
* @throws JSONException
*/
public static OpenSocialResponse getResponse(String _in)
{
OpenSocialResponse r = null;
if (_in[0] == '[') {
JsonArray responseArray = new JsonArray(_in);
r = new OpenSocialResponse();
for (int i=0; i<responseArray.Length; i++) {
JsonObject o = responseArray.GetObject(i);
if (o.Contains("id")) {
String id = o["id"].ToString();
r.addItem(id, escape(o.ToString()));
}
}
}
return r;
}
示例2: dispatchBatch
protected void dispatchBatch(JsonArray batch, HttpResponse response, ISecurityToken token)
{
// Use linked hash map to preserve order
List<IAsyncResult> responses = new List<IAsyncResult>(batch.Length);
// Gather all Futures. We do this up front so that
// the first call to get() comes after all futures are created,
// which allows for implementations that batch multiple Futures
// into single requests.
for (int i = 0; i < batch.Length; i++)
{
JsonObject batchObj = batch.GetObject(i);
RpcRequestItem requestItem = new RpcRequestItem(batchObj, token, jsonConverter);
responses.Add(HandleRequestItem(requestItem));
}
// Resolve each Future into a response.
// TODO: should use shared deadline across each request
List<Object> result = new List<object>();
for (int i = 0; i < batch.Length; i++)
{
JsonObject batchObj = batch.GetObject(i);
String key = null;
if (batchObj.Contains("id"))
{
key = batchObj["id"] as String;
}
result.Add(getJsonResponse(key, getResponseItem(responses[i]), null));
}
response.Output.Write(jsonConverter.ConvertToString(result));
}
示例3: createArrayRepresentation
/**
* Iterates through the objects _in the passed JsonArray object, recursively
* transforms each as needed, and returns a List of Java objects.
*
* @param a Object-oriented representation of a JSON array which is iterated
* through and returned as a List of Java objects
* @throws JSONException
*/
private static List<Object> createArrayRepresentation(JsonArray a)
{
List<Object> r = new List<Object>(a.Length);
for (int i=0; i<a.Length; i++) {
String member = a.GetString(i);
if (member.Length > 0 && member[0] == '{') {
JsonObject p = a.GetObject(i);
r.Add(new OpenSocialObject(createObjectRepresentation(p)));
} else if (member.Length > 0 && member[0] == '[') {
JsonArray p = (JsonArray)a[i];
List<Object> values = createArrayRepresentation(p);
foreach(var v in values) {
r.Add(v);
}
} else if (member.Length > 0) {
r.Add(member);
}
}
return r;
}