im getting my data as whole json,but i expect it to be grouped based on a common element among the result itself
Data from query
| firststring | secondstring | thirdstring |
|---|---|---|
| My Account | MyAccount | Menu1 |
| My Cart | MyFavourites | Menu1 |
| My Status | Status | Menu1 |
| Orders | orders | Menu2 |
| Damage Claim | DamageClaim | Menu2 |
my bean class
public class CommonThreeString implements Serializable{
private String firstString;
private String secondString;
private String thirdString;
public String getFirstString() {
return firstString;
}
public void setFirstString(String firstString) {
this.firstString = firstString;
}
public String getSecondString() {
return secondString;
}
public void setSecondString(String secondString) {
this.secondString = secondString;
}
public String getThirdString() {
return thirdString;
}
public void setThirdString(String thirdString) {
this.thirdString = thirdString;
}
}
My controller
@PostMapping("getMenuList")
public String getMenuList() throws ServiceException {
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
String json = null;
try {
json = ow.writeValueAsString(iService.getMenuList());
} catch (JsonProcessingException e) {
}
return json;
}
service implementation
public List<CommonThreeString> getMenuList() throws ServiceException {
List<CommonTwoLongThreeString> menuList = null;
try {
menuList = Impl.getMenuListByPortalId(Long.valueOf("input"));
//query works done here//
} catch (ServiceException e) {
}
return menuList;
}
here im getting output as
[
{
"firstString": "My Account",
"secondString": "MyAccount",
"thirdString": "Menu1"
},
{
"firstString": "My Cart",
"secondString": "MyFavourites",
"thirdString": "Menu1"
},
{
"firstString": "My Status",
"secondString": "Status",
"thirdString": "Menu1"
},
{
"firstString": "orders",
"secondString": "orders",
"thirdString": "Menu2"
},
{
"firstString": "Damage Claim",
"secondString": "DamageClaim",
"thirdString": "Menu2"
}
]
The output im expecting
Menu1
[
{
"firstString": "My Account",
"secondString": "MyAccount",
--"thirdString": "Menu1"
},
{
"firstString": "My Cart",
"secondString": "MyFavourites",
--"thirdString": "Menu1"
},
{
"firstString": "My Status",
"secondString": "Status",
--"thirdString": "Menu1"
}
]
Menu2
[
{
"firstString": "orders",
"secondString": "orders",
--"thirdString": "Menu2"
},
{
"firstString": "Damage Claim",
"secondString": "DamageClaim",
--"thirdString": "Menu2"
}
]
the third String need to be the grouping factor
im want to group properly like the above thanks in advance