У меня есть: Json:
{
"id" : "1",
"name": "John",
"id_client": "2",
...
}
Мои занятия:
public class Person{
private int id;
private String name;
private Client client;
...
}
public class Client{
private int id;
}
Как я десериализую id_client: "2", для объекта Client и set id (CLient)?
...
Map<String,Object> parsed = jsonParser.parse(jsonString);
Person thePerson = new Person(parsed);
...
public class Person {
...
public Person(Map<String,Object> parsed) {
id = Integer.getInteger(parsed.getString("id"));
name = parsed.getString("name");
int idClient = Integer.getInteger(parsed.getString("id_client"));
client = new Client(idClient);
}
...
}