I have a JSON.stringify(Array) that looks like
"[{\"Status\":\"Active\",\"DBID\":\"SB\",\"ID\":33},{\"Status\":\"Active\",\"DBID\":\"SB\",\"ID\":12}]"
And this is sent via an AXIOS command to a .NET Web API. The .NET Web API sends the string to a MS SQL stored proc.
My question is how can I convert the string back into standard JSON so I can use it in a stored proc. If I remove the leading and trailing double quotes and remove all of the backslashes ("") so that it looks like
'[{"Status":"Active","DBID":"SB","ID":33},{"Status":"Active","DBID":"SB","ID":12}]'
The stored proc runs fine using something like:
SELECT * FROM OPENJSON(@json)
If I run it with the backslashes I get
JSON text is not properly formatted. Unexpected character '' is found at position 2.
Should it be converted in the .NET Web API or the stored proc?
In the stored proc if I
set @json = replace(@json,'\','')
set @json = replace(@json,'"[','[')
set @json = replace(@json,']"',']')
But I was hoping for a cleaner solution.