Let's say I have the following object.
class Foo {
private String name;
private int age;
private Map<String, object> extra;
}
public static void main(String[] args) {
Foo foo = new Foo();
foo.name = "adam";
foo.age = 25;
foo.extra.put("hobbies", /** list of hobbies **/)
foo.extra.put("firends", /** list of friends **/)
// convert to json...
}
and I want the following output... Is it possible to do this by using custom serialize?
{
"name": "adam",
"age": 25,
"hobbies": [
{
"name": "footbal",
"level": 1
}
{
"name": "coding",
"level": 2
}
],
"friends": [
{
"id": 1
"name": "jack"
},
{
"id": 2
"name": "rose"
}
]
}