Пример #1
0
    /**
     * Transforms a raw JSON object string containing profile information for a
     * single user into an OpenSocialPerson instance with all profile details
     * abstracted as OpenSocialField objects associated with the instance.
     *
     * @param  _in The JSON object string to parse as an OpenSocialPerson object
     * @throws OpenSocialRequestException
     * @throws JSONException
     * @throws IllegalAccessException
     * @throws InstantiationException
     */
    public static OpenSocialPerson parseAsPerson(String _in)
    {
        if (_in == null)
        {
            throw new OpenSocialRequestException(
                      "Response item with given key not found");
        }

        JsonObject root  = (JsonObject)JsonConvert.Import(_in);
        JsonObject entry = getEntryObject(root);

        OpenSocialPerson p =
            (OpenSocialPerson)parseAsObject(entry, typeof(OpenSocialPerson));

        return(p);
    }
Пример #2
0
    /**
     * Transforms a raw JSON object string containing profile information for a
     * group of users into a list of OpenSocialPerson instances with all profile
     * details abstracted as OpenSocialField objects associated with the
     * instances. These instances are then added to a Java List which
     * gets returned.
     *
     * @param  _in The JSON object string to parse as a List of OpenSocialPerson
     *         objects
     * @throws OpenSocialRequestException
     * @throws JSONException
     * @throws IllegalAccessException
     * @throws InstantiationException
     */
    public static List <OpenSocialPerson> parseAsPersonCollection(String _in)
    {
        if (_in == null)
        {
            throw new OpenSocialRequestException(
                      "Response item with given key not found");
        }

        JsonObject root           = (JsonObject)JsonConvert.Import(_in);
        JsonArray  entries        = getEntryArray(root);
        List <OpenSocialPerson> l = new List <OpenSocialPerson>(entries.Length);

        for (int i = 0; i < entries.Length; i++)
        {
            JsonObject entry = entries.GetObject(i);

            OpenSocialPerson p =
                (OpenSocialPerson)parseAsObject(entry, typeof(OpenSocialPerson));

            l.Add(p);
        }

        return(l);
    }