title: Combine one Json with another Json (JAVA)
body: <p>So I already succeed with one Json to get it all worked. Now I have another class where I want to get only one attribute. I have now a moviedatabase class (which work with JSON and gets all the information) and now I want to add a Trailer which is from Youtube API. so basically I need it to be added into the same JSON to make it easier for me in the future to get it into a HTML. the only problem is I cant get it work. I get a syntax error JSON when using this method.</p>
  
  <p><strong>EDIT CODE 1.1:</strong> </p>
  
  <p>Youtube attribute: </p>
  
  <pre><code>public class FilmAttribut {
      private String title = "";
      private String release = "";
      private int vote = 0;
      private String overview = "";
      private String poster = "";
      private String trailer = "";
  
      // getters + setters stripped    
  }
  </code></pre>
  
  <p>Youtube class: </p>
  
  <pre><code>public class Youtube {
  
      FilmAttribut movie = new FilmAttribut();
      public void search(String trailer, FilmAttribut in) {
  
          HttpResponse&lt;JsonNode&gt; response;
          try {
              response = Unirest.get("https://www.googleapis.com/youtube/v3/search?key=[app key here]&amp;part=snippet")
                      .queryString("q", trailer + " trailer")
                      .asJson();
  
              JsonNode json = response.getBody();
              JSONObject envelope = json.getObject();
              JSONArray items = envelope.getJSONArray("items");
  
              in.setTrailer("https://youtu.be/" + items.getJSONObject(0).getJSONObject("id").getString("videoId")); //Gives me error here
  
          }
          catch (JSONException e) {
  
              e.printStackTrace(); 
          } catch (UnirestException e) {
              e.printStackTrace();
          }
  
          return null;
  
      }
  }
  </code></pre>
  
  <p>and main method </p>
  
  <pre><code>public class WebService {
  
      public static void main(String[] args) {
          setPort(1337);
  
          Gson gson = new Gson();
          Youtube yt = new Youtube();
          MovieDataBase mdb = new MovieDataBase();
  
  
  
  
  get("/search/:movie", (req, res) -&gt;  {
              String titel = req.params(":movie");
              FilmAttribut film = mdb.searchMovie(titel); 
              yt.search(titel, film);
              String json = gson.toJson(film);
              return json;
  
          });
  </code></pre>
  
  <p>So I think the problem is that you can't have two <code>gson.toJson(film) + gson.toJson(trailer);</code> Because it makes the JSON twice, where one time is for the film (aka. movie) and then a new json is created with trailer which make the syntax error.</p>
  
  <p>So my real question is, is it possible to have another class like I have now youtube. to send the information to a attribute class where I have all my attributes and then run it in main-method so that I can get all the JSON in one JSON. </p>