Otrzymuje takie dane:
{
"name": "test 1234",
"desc": "test 568",
"number": 1
},
{
"name": "test 1234",
"desc": "test 568",
"number": 2
},
{
"name": "cos innego 1234",
"desc": "cos inego 568",
"number": 3
},
{
"name": "jeszcze cos innego 1234",
"desc": "jeszcze cos inego 568",
"number": 4
}
gdy wykonuje to:
....
List<MainObj> result = new ArrayList<>();
for (Adr adr : items) {
MainObj mainObj = new MainObj();
mainObj.setName(adr.getName());
mainObj.setDesc(adr.getDesc());
mainObj.setNumber(adr.getNumber());
result.add(mainObj);
}
return result;
a teraz jak to przerobić abym otrzymał cos w stylu:
{
"name": "test 1234",
"desc": "test 568",
"numbers": [1,2]
},
{
"name": "cos innego 1234",
"desc": "cos inego 568",
"numbers": [3]
},
{
"name": "jeszcze cos innego 1234",
"desc": "jeszcze cos inego 568",
"numbers": [4]
}
czyli scala się jeśli pole name i desc są takie same a number robi robi się listą