Reputation: 7204
I've created JSON which is a list of cars:
public class Car {
@Expose
public String producer;
@Expose
public String model;
....
}
and I create JSON with :
Gson gson = new Gson();
gson.toJson(car.getList());
But now I want to add extra field outside the list inside JSON.
Upvotes: 0
Views: 415
Reputation: 2403
You should define another container class having the car list as attribute and the new field your talking about. Gson will serialize this container object and produce the JSON object you want.
Upvotes: 1