JSONObject fromJSONObject = json.getJSONObject("from");
from = new CategoryJSONImpl(fromJSONObject);
}
if (!json.isNull("tags")) {
JSONObject tagsJSONObject = json.getJSONObject("tags");
JSONArray list = tagsJSONObject.getJSONArray("data");
final int size = list.length();
tags = new PagableListImpl<Tag>(size, tagsJSONObject);
for (int i = 0; i < size; i++) {
TagJSONImpl tag = new TagJSONImpl(list.getJSONObject(i));
tags.add(tag);
}
} else {
tags = new PagableListImpl<Tag>();
}
name = getRawString("name", json);
icon = getURL("icon", json);
picture = getURL("picture", json);
source = getURL("source", json);
if (!json.isNull("height")) {
height = getPrimitiveInt("height", json);
}
if (!json.isNull("width")) {
width = getPrimitiveInt("width", json);
}
if (!json.isNull("images")) {
images = new ArrayList<Photo.Image>();
JSONArray imagesJSONArray = json.getJSONArray("images");
for (int i = 0; i < imagesJSONArray.length(); i++) {
JSONObject image = imagesJSONArray.getJSONObject(i);
images.add(new PhotoJSONImpl.ImageJSONImpl(image));
}
} else {
images = Collections.emptyList();
}
link = getURL("link", json);
if (!json.isNull("place")) {
JSONObject placeJSONObject = json.getJSONObject("place");
place = new PlaceJSONImpl(placeJSONObject);
}
createdTime = getISO8601Datetime("created_time", json);
updatedTime = getISO8601Datetime("updated_time", json);
if (!json.isNull("position")) {
position = getPrimitiveInt("position", json);
}
if (!json.isNull("comments")) {
JSONObject commentsJSONObject = json.getJSONObject("comments");
if (!commentsJSONObject.isNull("data")) {
JSONArray list = commentsJSONObject.getJSONArray("data");
final 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);
}
} else {
comments = new PagableListImpl<Comment>(1, commentsJSONObject);
}
} else {
comments = new PagableListImpl<Comment>(0);
}
if (!json.isNull("likes")) {
JSONObject likesJSONObject = json.getJSONObject("likes");
if (!likesJSONObject.isNull("data")) {
JSONArray list = likesJSONObject.getJSONArray("data");
final int size = list.length();
likes = new PagableListImpl<Like>(size, likesJSONObject);
for (int i = 0; i < size; i++) {
LikeJSONImpl like = new LikeJSONImpl(list.getJSONObject(i));
likes.add(like);
}
} else {
likes = new PagableListImpl<Like>(1, likesJSONObject);
}