Home > Back-end >  How can use Gson. ToJson change finally get a json string tree structure?
How can use Gson. ToJson change finally get a json string tree structure?

Time:03-20

Such as an object existing User
 
Public class User {
private int code;
private String name;
private int age;
}

Directly through the gson. ToJson (user) can get the following string:
 
{" code ": 100," name ":" Tom ", "age" : 18}

But how to through the gson library status code and the separation of data required, get the string?
 
{" code ": 100," data ": {" name" : "Tom", "age" : 18}}
  • Related