title: Gson - Serialize Nested Object as Attributes
body: <p>Is there an easy way to convert how a nested Object is converted to JSON? I'm trying to just create one JSON object to match the back-end. I'm using Retrofit for my networking, which converts an Object to JSON with Gson. </p>
  
  <p>I don't have access to any code between network call and the convertion, so I'm trying to find a clean way to modify how the Object is converted, either through the GsonBuilder, or Annotations.</p>
  
  <pre><code>// Automatically converted to JSON with passed in Gson.
  Call&lt;myObject&gt; search( @Body foo myFoo ); 
  </code></pre>
  
  <hr>
  
  <pre><code>public class foo {
      String text = "boo";
      bar b = new bar();
  }
  
  public class bar {
      String other = "moo";
  }
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>{ "text": "boo", "b" { "other": "moo" } }
  </code></pre>
  
  <p>Desired Result:</p>
  
  <pre><code>{ "text": "boo", "other": "moo" }
  </code></pre>
  
  <p>Thanks for your help. :)</p>