java - Group duplicates values into single hashmap -




using list<map<string, object>> have merge same groupname, product_attributes converted arrays. receiving below data in list<map<string, object>> data

following method converts data

private list<map<string, object>> mapdataforclient(list<map<string, object>> data, list<long> ids) { list<map<string,object>> list = new arraylist<>();          for(map<string, object> d: data) {             map<string, object> group = new hashmap<>();              string groupname = (string) d.get("group_name");             group.put("groupname", groupname);             string productid = (string) d.get("product_id");             string productattributetype = (string) d.get("product_attribute_type");             string productattributename = (string) d.get("product_attribute_name");             map<string, object> types = new hashmap<>();              string[] values = alterbyids(productattributename, productid, ids); //this function gives arrays of string              types.put("values", values);             types.put("type", productattributetype);             group.put("product_attributes", types);             list.add(group);         }         return list; 

data following

{     "product_group_attribute": [        {         "product_attributes": {             "values": [                 "not applicable",                 "applicable",                 "yes"             ],             "type": "camera compatibility"         },         "groupname": "certifications & listings"         },         {             "product_attributes": {                 "values": [                     "hd camera",                     "18px camera",                     "dslr camera"                 ],                 "type": "camera"             },             "groupname": "key specs"         },         {             "product_attributes": {                 "values": [                     "100 meter",                     " -- ",                     "160 meter"                 ],                 "type": "flight"             },             "groupname": "key specs"         },         {             "product_attributes": {                 "values": [                     " -- ",                     " -- ",                     " -- "                 ],                 "type": "range"             },             "groupname": "key specs"         }     ] } 

how can group hashmap value (groupname) can have merged same value 1 value?

required data

{         "product_group_attribute": [            {             "product_attributes": {                 "values": [                     "not applicable",                     "applicable",                     "yes"                 ],                 "type": "camera compatibility"             },             "groupname": "certifications & listings"             },             {                 "product_attributes": [{                     "values": [                         "hd camera",                         "18px camera",                         "dslr camera"                     ],                     "type": "camera"                 }, {                     "values": [                         "100 meter",                         " -- ",                         "160 meter"                     ],                     "type": "flight"                 }, {                     "values": [                         " -- ",                         " -- ",                         " -- "                     ],                     "type": "range"                 }],                 "groupname": "key specs"             }         ]     } 





wiki

Comments

Popular posts from this blog

python - Read npy file directly from S3 StreamingBody -

python - Minimize function with Scipy minimize -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -