I have list of hashmap and I want to join value if key is same below I have mentioned input and expected output .I have gone through many question answer related to this problem still couldn't found solution.
INPUT :
[
{
"id": "316",
"text1": true
},
{
"id": "316",
"text2": true
},
{
"id": "315",
"text1": true
},
{
"id": "315",
"text2": true
}
]
OUTPUT:
[
{
"id": "316",
"text1": true,
"text2": true
},
{
"id": "315",
"text1": true,
"text2": true
}
]
Code Snippet :
List list1= new ArrayList();
HashMap details= new HashMap();
details.put("id", "305");
details.put("text1",true);
list1.add(details);
HashMap details2= new HashMap();
details2.put("id", "305");
details2.put("text2",true);
list1.add(details2);