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.
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.
// Automatically converted to JSON with passed in Gson.
Call<myObject> search( @Body foo myFoo );
public class foo {
String text = "boo";
bar b = new bar();
}
public class bar {
String other = "moo";
}
Result:
{ "text": "boo", "b" { "other": "moo" } }
Desired Result:
{ "text": "boo", "other": "moo" }
Thanks for your help. :)