0
나는 모든 부가 요소 GSON에 JSON에 속성을 추가하는 방법은 무엇입니까?
를 반환) 나는 GSON이 (Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
String jsonG = gson.toJson(OrderShoppingCart.getOrders());
//OrderShoppingCart.getOrders을 다음 내장 다음과 같은 클래스를
public class OrderShoppingCart {
@Expose
@SerializedName("id")
private String _id;
@Expose
@SerializedName("quantity")
private int _quantity;
private String _description;
private String _name;
private int _price;
@Expose
@SerializedName("selections")
private List<SelectionShoppingCart> _selections;
public OrderShoppingCart(String id, int quantity, String description, String name,int price, List<SelectionShoppingCart> selections) {
_id = id;
_quantity = Integer.valueOf(quantity);
_description = description;
_name = name;
_price = price;
_selections = selections;
}
//HERE GET AND SETTER
}
을하고 난 다음
[{"id":"525b207b16b1e9ca33000143","selections":[],"quantity":1}]
있어
하지만이 번호가 필요합니다.
{items:[{"id":"525b207b16b1e9ca33000143","selections":[],"quantity":1}]}
내가 누락 된 부분을 어떻게 추가 할 수 있습니까?
Gracias, 작동 여부 – cc69cc