比如現有一個物件User
public class User{
private int code;
private String name;
private int age;
}
直接通過gson.toJson(user)能得到以下字串:
{"code":100,"name":"tom","age":18}
但是如何通過gson庫進行狀態碼和所需資料的分離,得到這樣的字串呢?
{"code":100,"data":{"name":"tom","age":18}}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/269009.html
標籤:Web 開發
