we are getting the list output values below
({1=huffs, 2=45}, {1=huffy, 2=49}, {1=huff, 2=44}, {}, {})
I want the output as below for example:
({huffs,45}, {huffy, 49}, {huff, 44}, {}, {})
we are getting the list output values below
({1=huffs, 2=45}, {1=huffy, 2=49}, {1=huff, 2=44}, {}, {})
I want the output as below for example:
({huffs,45}, {huffy, 49}, {huff, 44}, {}, {})
Your collection seems to be a list of maps. If it's just some json string, make sure to make a list of maps of it. Then try this:
public List<List<Object>> DoTheJob(List<Map<Integer,Object>> myMapList){
List<List<Object>> resultList = new List<List<Object>>(); // your result list of lists
for(Map<Integer,Object> m : myMapList)
{
List<Object> myTupple = new List<Object>();
for (Integer key : m.keySet())
{
myTupple.Add(m.get(key));
}
resultList.Add(myTupple);
}
return resultList;
}
This should do the trick. myMapList
is your input collection here ({1=huffs, 2=45}, {1=huffy, 2=49}, {1=huff, 2=44}, {}, {}
). I think you should remove empty elements first. Make sure to make your collection to be in form of List<Map<Integer,Object>>
.
The result is a list of lists, where each internal list is in the form of {"huff", 45}
.