need to get a Map from json, there is: json
{ "id":"1", "name":"aaa", "operations":[ { "type":"add", "value":"1" }, { "type":"delete", "value":"2" } ] } java
public class User { private int id; private String name; private List<Operations> operations; public User(int id, String name, Operations operations) { this.id = id; this.name = name; this.operations = this.operations; } // geters and seters } public class Operations { private String type; private String value; public Operations(String type, String value) { this.type = type; this.value = value; } // geters and seters } gson
// String userData = ... User user = gson.fromJson(userData, User.class); How to make in user instead of List was a Map and it was possible to get operations by key, for example user.getOperations.get("add");