生成JSON:
Gson gson =newGson();
User user =newUser("小红",24);
String jsonObject = gson.toJson(user).tostring(); // {"name":"小红","age":24}
解析JSON:
Gson gson =newGson();
String jsonString ="{\"name\":\"小红\",\"age\":24}";
User user = gson.fromJson(jsonString, User.class);