Пример #1
0
  /**
   * 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;
  }