That JSON looks fine to me… another way of representing one to many relations might be something like this
[
{
"desc": "Capital,Summary etc",
"datadesc": [
"Counts of capital and summary ",
"Testing of capital and summary ",
"Testing of capital and summary "
]
},
{
"desc": "First Reports",
"datadesc": [
"Completed Successfully ",
" Still Pending ",
"Failed twice ",
"Re attempting ... "
]
}
]
… but personally I’d rather keep the JSON response to be as simple as possible, so it’s easier to extend with additional relations (say). And you can still convert it to a more dedicated structure (like the above) on the client side where required, for example like so:
const data = json.dataInfo.reduce((result, current) => {
const entry = result.find(({ desc }) => current.desc === desc)
const { desc, datadesc } = current
if (entry) {
entry.datadesc.push(datadesc)
} else {
result.push({ desc, datadesc: [datadesc] })
}
return result
}, [])