Пример #1
0
  public static Photo fromJsonSingle(JSONObject jsonObject) {
    Photo b = new Photo();
    // Deserialize json into object fields
    try {
      b.id = jsonObject.getInt("id");
      b.album_id = jsonObject.getInt("album_id");
      b.owner_id = jsonObject.getInt("owner_id");
      b.photo_75 = jsonObject.getString("photo_75");
      b.photo_130 = jsonObject.getString("photo_130");
      // b.photo_604 = jsonObject.getString("photo_604");
      // b.photo_807 = jsonObject.getString("photo_807");//TODO not sure about those photo sizes
      // b.width = jsonObject.getInt("width");
      // b.height = jsonObject.getInt("height");
      // b.text = jsonObject.getString("text");
      // b.access_key = jsonObject.getString("access_key");
      // b.post_source_type = jsonObject.getJSONObject("post_source").getString("type");
      // b.comments_count = jsonObject.getJSONObject("comments").getInt("count");
      // b.likes_count = jsonObject.getJSONObject("likes").getInt("count");
      // b.reposts_count = jsonObject.getJSONObject("reposts").getInt("count");

    } catch (JSONException e) {
      e.printStackTrace();
      Log.e(TAG, "Error processing JSONObject  " + jsonObject.toString());
      return null;
    }
    // Return new object
    return b;
  }