I have the following class
class MyList{
List<String> names ;
}
and a Json structure
{
"names" :[
{"name":"John"},
{"name":"David"}
]
}
As you can see the JSON
structure isn't exactly mapping the class
structure.
Is there an easy way to map the json to the desired class?
So per say the following:
Namese names = new Gson().fromJson(json, Names.class);
System.out.println(new Gson().toJson(names);
will printout :
["John","David"]
If there isn't a way using Gson
, is there any other library that let's me do it easily?
NOTE
by using word easy I mean without manually looping through our json structure and create the class.