I have the following:
x = [{"value":"cricket","key":"sports"},{"value":"hockey","key":"c"},{"value":"maharastra","key":"states"},{"value":"haryana","key":"states"},{"value":"facebook","key":"company"},{"value":"google","key":"company"}]
y = [{"Id":"India","label":"sports"},{"Id":"India","label":"states"},{"Id":"usa","label":"company"}]
For each label of Id of jsvalue(y) is mapped to key in in another jsValue(x), I want to map those to form below structure:
{
"Mergedjson": [
{
"label": "India",
"children": [
{
"label": "Sports",
"children": [
{
"value": "Cricket",
"enable": false
},
{
"value": "hockey",
"enable": false
}
]
},
{
"label": "sates",
"children": [
{
"value": "maharastra",
"enable": false
},
{
"value": "Haryana",
"enable": false
}
]
}
]
},
{
"label": "USA",
"children": [
{
"label": "companies",
"children": [
{
"value": "google",
"enable": false
},
{
"value": "facebook",
"enable": false
}
]
}
]
}
]
}
All I can think of is to directly merge these jsons where I end up with having one single jsValue
s of both x and y but not the above mentioned structure.
Play itself and play json espicially not a best thing to work with but something like this will work:
and i would advice you to throw play json to window and use circe instead.