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


C# JsonArray.GetObject方法代码示例

本文整理汇总了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;
  }
开发者ID:s7loves,项目名称:pesta,代码行数:31,代码来源:OpenSocialJsonParser.cs

示例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));
        }
开发者ID:s7loves,项目名称:pesta,代码行数:31,代码来源:rpcController.cs

示例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;
  }
开发者ID:s7loves,项目名称:pesta,代码行数:33,代码来源:OpenSocialJsonParser.cs


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