Пример #1
0
 private void init(JSONObject json) throws FacebookException {
   try {
     id = getRawString("id", json);
     if (!json.isNull("from")) {
       JSONObject fromJSONObject = json.getJSONObject("from");
       from = new IdNameEntityJSONImpl(fromJSONObject);
     }
     if (!json.isNull("tags")) {
       JSONObject tagsJSONObject = json.getJSONObject("tags");
       JSONArray list = tagsJSONObject.getJSONArray("data");
       int size = list.length();
       tags = new PagableListImpl<IdNameEntity>(size, tagsJSONObject);
       for (int i = 0; i < size; i++) {
         IdNameEntityJSONImpl tag = new IdNameEntityJSONImpl(list.getJSONObject(i));
         tags.add(tag);
       }
     }
     if (!json.isNull("place")) {
       JSONObject placeJSONObject = json.getJSONObject("place");
       place = new PlaceJSONImpl(placeJSONObject);
     }
     if (!json.isNull("application")) {
       JSONObject applicationJSONObject = json.getJSONObject("application");
       application = new ApplicationJSONImpl(applicationJSONObject);
     }
     createdTime = getISO8601Datetime("created_time", json);
     if (!json.isNull("likes")) {
       JSONObject likesJSONObject = json.getJSONObject("likes");
       JSONArray list = likesJSONObject.getJSONArray("data");
       int size = list.length();
       likes = new PagableListImpl<IdNameEntity>(size, likesJSONObject);
       for (int i = 0; i < size; i++) {
         IdNameEntityJSONImpl like = new IdNameEntityJSONImpl(list.getJSONObject(i));
         likes.add(like);
       }
     }
     message = getRawString("message", json);
     if (!json.isNull("comments")) {
       JSONObject commentsJSONObject = json.getJSONObject("comments");
       JSONArray list = commentsJSONObject.getJSONArray("data");
       int size = list.length();
       comments = new PagableListImpl<Comment>(size, commentsJSONObject);
       for (int i = 0; i < size; i++) {
         CommentJSONImpl comment = new CommentJSONImpl(list.getJSONObject(i));
         comments.add(comment);
       }
     }
     type = getRawString("type", json);
   } catch (JSONException jsone) {
     throw new FacebookException(jsone.getMessage(), jsone);
   }
 }
Пример #2
0
 private void init(JSONObject json) throws FacebookException {
   try {
     id = getRawString("id", json);
     if (!json.isNull("from")) {
       JSONObject fromJSONObject = json.getJSONObject("from");
       from = new IdNameEntityJSONImpl(fromJSONObject);
     }
     if (!json.isNull("to")) {
       JSONObject toJSONObject = json.getJSONObject("to");
       JSONArray toJSONArray = toJSONObject.getJSONArray("data");
       to = new ArrayList<IdNameEntity>();
       for (int i = 0; i < toJSONArray.length(); i++) {
         to.add(new IdNameEntityJSONImpl(toJSONArray.getJSONObject(i)));
       }
     }
     message = getRawString("message", json);
     createdTime = getISO8601Datetime("created_time", json);
     updatedTime = getISO8601Datetime("updated_time", json);
     if (!json.isNull("comments")) {
       JSONObject commentsJSONObject = json.getJSONObject("comments");
       JSONArray list = commentsJSONObject.getJSONArray("data");
       int size = list.length();
       comments = new PagableListImpl<Comment>(size, commentsJSONObject);
       for (int i = 0; i < size; i++) {
         CommentJSONImpl comment = new CommentJSONImpl(list.getJSONObject(i));
         comments.add(comment);
       }
     }
   } catch (JSONException jsone) {
     throw new FacebookException(jsone.getMessage(), jsone);
   }
 }