I am trying to find an effective way to insert a property into an existing json array with out having to do it by index. For example say we had:
DECLARE @json NVARCHAR(MAX);
SET @json = N'
{
"objs":[
{"id":1},
{"id":2}
]
}
'
How do I add a property to each object in the array? What I would like to do is something like this:
JSON_MODIFY(@json,'$.objs[].parent_id',1);
But this does not work because I did not provide an array index. I am sure there is a simple solution to this, but I could not find one in the docs.