I have the user table stored as following:
|---------------------|------------------|-------------------------------------------------------------|
| id | name | address
|---------------------|------------------|-------------------------------------------------------------|
| 1 | ken | {"street":"Street 1","city":"City1", "country":"USA"} |
|---------------------|------------------|-------------------------------------------------------------|
My POJO:
public class User{
private int id;
private String name;
private String address;
//setters and getters
}
In my RESTful services i wish to have the following JSON as response when i call for my API:
{
"id": 1,
"name": "ken",
"address":{
"street":"Street 1",
"city":"City1",
"country":"USA"
}
}
I can do this by changing my address in POJO to a address object, then map the string into the adress object.
But is there any other ways that i keep my address as string in POJO, then it will render as JSON?