Id like to represent the class object as JSON. For example, if I have class definitions as follows:
public class MyClass {
String myName;
int myAge;
MyOtherClass other;
}
public class MyOtherClass {
double myDouble;
}
I would like to get the following nested JSON from a class object of type MyClass:
{
myName: String,
myAge: int,
other: {
myDouble: double;
}
}
EDIT:
I do not want to serialize instances of these classes, I understand how to do this with GSON. I want to serialize the structure of the class itself, so given the Object's own class, I can generate JSON that recursively breaks the fields of the class into standard objects like String, Double, etc.
source
share