public static Actor fromJson(JSONObject jsonObject, Movie movie) { Actor actor = new Actor(); try { actor.name = jsonObject.getString("name"); actor.movieId = movie.movieId; actor.movie = movie; } catch (JSONException e) { e.printStackTrace(); return null; } return actor; }
public static ArrayList<Actor> fromJson(JSONArray jsonArray, Movie movie) { ArrayList<Actor> actors = new ArrayList<Actor>(jsonArray.length()); for (int i = 0; i < jsonArray.length(); i++) { JSONObject actorJSON = null; try { actorJSON = jsonArray.getJSONObject(i); } catch (Exception e) { e.printStackTrace(); continue; } Actor actor = Actor.fromJson(actorJSON, movie); if (actor != null) { actors.add(actor); } } return actors; }