Consolidate data from Multivalued Maps in 1 Map or List in Android

0

I have this JSON and I am mapping the "Users" with GSON but I need to consolidate the maps (in this example 2, but it can be more) in only 1 Map or 1 List because I need to send the consolidated to a Custom Adapter , like you can see, I have 2 user lists (2 JSON objects) and I can access each list / object of users and attributes without problem, but I need to create only 1 map or list, is there any way to consolidate those multivalue maps into just one?

here is the JSON:

[{
"id": 999098,
"name": "Legendary Users",
"users": {
    "98087ffg5": {
        "Age": 20,
        "name": "dighak"
    },
    "0987499gg8": {
        "Age": 18,
        "name": "kijhg"
    },
    "1231ghty56": {
        "Age": 19,
        "name": "ramn1"
    }
}
    },
         {
"id": 999098,
"name": "Best Users",
"users": {
    "12312bvf123": {
        "Age": 20,
        "name": "thispa"
    },
    "50827gh65": {
        "Age": 21,
        "name": "vista1"
    }
}}]

I'm mapping them with the Response.class

 public class Response {

    private int id;
    private String name;

    private Map<String,UsersBean> users = new LinkedHashMap<>();

    public int getId() {return id;}
    public void setId(int id) {this.id = id;}
    public String getName() {return name;}
    public void setName(String name) {this.name = name;}

    public Map<String,UsersBean> getUsers() {return users;}

    public void setUsers(Map<String,UsersBean> users) {this.users = users;}

   public static class UsersBean {

    private int Age;
    private String name;

    public int getAge() {return Age;}
    public void setAge(int Age) {this.Age = Age;}
    public String getName() {return name;}
    public void setName(String name) {this.name = name;}
}}

As you can see, I must access each Map / Users list in the following way: response.get(0).getUsers().get("key").getName(); but I need consolidation N number of maps in 1.

Will they know of any way in which you can consolidate the data of the maps into 1 alone or in a list? what I need is to consolidate the data of 2 or more maps in 1 and be able to access it in the following way, for example, take note that they are multivalue maps:

mapa/lista.getUsers().get("key").getName();
    
asked by LuDev 10.04.2018 в 22:22
source

0 answers