distal-attribute
distal-attribute
distal-attribute
distal-attribute

JSON exporter does not escape strings

Miroticey1 posted 3 months ago in Import/Export

I want to export a result that contains HTML text column. I chose JSON because processing it would be easy. The exported JSON is invalid because the strings are not escaped, e.g. double quotes are unescaped.

kalvaro posted 3 months ago

I can confirm that:

SELECT 'one"two' AS 'two"three'

... exports as:

{
    "table": "UnknownTable",
    "rows":
    [
        {
            "two"three": "one"two"
        }
    ]
}

(I admit I had never used it before.)

ansgar posted 3 months ago

Fixed in r5135

Miroticey1 posted 3 months ago

Thanks, I'm now on r5135 and the JSON is valid. However, HTML special chars get entity encoded and thats not needed. JSON strings can contain any Unicode character:

JSON string reference

kalvaro posted 3 months ago

HTML special chars get entity encoded and thats not needed.

What do you mean exactly? JSON has nothing to do with HTML so either that being not needed it would be plain wrong. But I cannot reproduce it :-?

Miroticey1 posted 3 months ago

Sorry, should have included an example. I'm referring to a text column that contains HTML text. I want to export a result that contains this HTML text column. See this example. This forum drops HTML tags and entities, so I had to resort to codepad.

kalvaro posted 3 months ago

Thank you. You're right in everything (bogus HTML escape in JSON and forum not being able to handle angle brackets even in code blocks).

ansgar posted 3 months ago

r5137 escapes quotes in JSON "query" values, and removes encoding of HTML entities.

Please login to leave a reply, or register at first.