Re: JSON_ARRAY_APPEND adding escape slash
Posted by: Derek McKinnon
Date: August 21, 2022 11:05PM

OK, this worked.

-- SET @i = NULL;
SET @i = JSON_ARRAY(JSON_OBJECT('a', '1', 'b', '2'));
SET @j = JSON_OBJECT('c', '3', 'd', '3');
-- SET @j = CAST('{"a": "1"}' AS JSON);
SET @a = IF( @i IS NULL OR JSON_TYPE(@i) != 'ARRAY',
JSON_ARRAY_APPEND(@i, '$', JSON_OBJECT('c', '3', 'd', '3'))
SELECT @j, @a

Now I have to work out how to pass that string type object in to a function.

Options: ReplyQuote

Written By
Re: JSON_ARRAY_APPEND adding escape slash
August 21, 2022 11:05PM

Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.