Beispiel #1
0
  /**
   * Parses the passed JSON string into an OpenSocialResponse object -- if the
   * passed string represents a JSON object, it is added to the returned
   * object keyed on the passed ID.
   * 
   * @param  _in The complete JSON string returned from an OpenSocial container
   *            _in response to a request for data
   * @param  id The string ID to tag the JSON object string with as it is added
   *            to the OpenSocialResponse object
   * @throws JSONException
   */
  public static OpenSocialResponse getResponse(String _in, String id)
    {

    OpenSocialResponse r = null;

    if (_in[0] == '{') {
      r = new OpenSocialResponse();
      r.addItem(id, escape(_in));
    } else if (_in[0] == '[') {
      return getResponse(_in);
    }

    return r;
  }
Beispiel #2
0
    /**
     * Parses the passed JSON string into an OpenSocialResponse object -- if the
     * passed string represents a JSON object, it is added to the returned
     * object keyed on the passed ID.
     *
     * @param  _in The complete JSON string returned from an OpenSocial container
     *            _in response to a request for data
     * @param  id The string ID to tag the JSON object string with as it is added
     *            to the OpenSocialResponse object
     * @throws JSONException
     */
    public static OpenSocialResponse getResponse(String _in, String id)
    {
        OpenSocialResponse r = null;

        if (_in[0] == '{')
        {
            r = new OpenSocialResponse();
            r.addItem(id, escape(_in));
        }
        else if (_in[0] == '[')
        {
            return(getResponse(_in));
        }

        return(r);
    }
Beispiel #3
0
  /**
   * 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;
  }
Beispiel #4
0
    /**
     * 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);
    }