My json is
[
{
"id": null,
"st": "value1",
"key": 1,
"value": "i am calling from",
"description": null
},
{
"st": "value2",
"key": 5,
"value": "i am calling from",
"description": null
},
{
"id": 25,
"st": "value3",
"key": 1,
"value": "i am calling from",
"description": null
}
]
I need to iterate the id (only when it is null and no id key) with a number and form back the same json as below even though the key (id) is missing . It has to be automatic id generation because I never know how many elements are present in this aggregation.
[
{
"id": 1,
"st": "value1",
"key": 1,
"value": "i am calling from",
"description": null
},
{
"id": 2,
"st": "value2",
"key": 5,
"value": "i am calling from",
"description": null
},
{
"id": 25,
"st": "value3",
"key": 1,
"value": "i am calling from",
"description": null
}
]
I believe RECURSIVE CTE work, but I'm unable to find a way to work this out. Please help