Similarly to this question about json_extract_path_text, when I run this query in Redshift, I would expect json_extract_array_element_text to remove the backslashes from the "\"b\"" value:
select
j,
json_extract_array_element_text(j, 0) as a
from (select '["\\"b\\""]' as j);
Instead, it appears that the string value is extracted verbatim, and the results look like this:
["\"b\""]
\"b\"
Is this intentional? If yes, what would be the idiomatic way to remove the backslashes?
'["\\"b\\""]'is parsed as the string["\"b\""]. But a JSON parser should parse that as an array with a single element, the string"b", not as an array containing the string\"b\". There is nothing in thejson_extract_array_element_text(orjson_extract_path_text, for that matter) to suggest that they are not following the JSON standard."b"not\"b\"JSON.parse('["\\"b\\""]')[0].length(gives 3) and Redshiftselect length(json_extract_array_element_text('["\\"b\\""]', 0))(gives 5)