common_schema icon indicating copy to clipboard operation
common_schema copied to clipboard

Escaped double quotes don't work in json_to_xml

Open jfneis opened this issue 5 years ago • 3 comments

SQL: select common_schema.json_to_xml('{"key":"ab"cd"}') Expected result: ab\cd Current result: NULL

The problem is in _get_json_token line 166, as substr won't find the "" char as it expects.

Don't know how to solve it yet.

jfneis avatar Jan 08 '19 19:01 jfneis

FWIW I wrote these json_to_xml functions at a time when MySQL had no JSON support, but did have XML/Xpath support.

These days MySQL has good JSON function library. If possible, I'd advise using them.

shlomi-noach avatar Jan 08 '19 19:01 shlomi-noach

@shlomi-noach yeap, new mysql JSON features are in our backlog, but right now we have some legacy sheets that depend on XML, unfortunately. :(

thanks for pointing out!

jfneis avatar Jan 08 '19 20:01 jfneis

@jfneis

Also {"key":"ab"cd"} isn't valid JSON format https://jsonlint.com/?json={%22key%22:%22ab%22cd%22}

{"key":"ab\"cd"} is valid JSON format and escaping. https://jsonlint.com/?json={%22key%22:%22ab%22cd%22}

RaymondNijland avatar Aug 28 '19 14:08 RaymondNijland