I am trying to serialize an object. I have the following structure:
Class A{
String aField1;
String aField2;
B bObj;
}
Class B{
String bField1;
String bField2;
String bField3;    
}
I am trying to serialze class A and B objects to send them to server. When I am serializing Class A object, it gives me
{
 aField1: "abc",
 aField2: "def",
 B: {
    bField1: "mnp",
    bField2: "qrt",
    bField3: "xyz",
    }
}
And serializing Class B obj:
{
 bField1: "mnp",
 bField2: "qrt",
 bField3: "xyz",
}
But I want Class A object like this:
{
 aField1: "abc",
 aField2: "def",
 B: {
    bField1: "mnp"
    }
}
I am currently using GSON library to accomplish this. I want to remove extra key value pairs when interacting with server. How can I do this?
 
     
    