JSON exporter does not escape strings

[expired user #10323]'s profile image [expired user #10323] posted 7 years ago in Import/Export Permalink

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's profile image kalvaro posted 7 years ago Permalink

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.)

Code modification/commit 462dcba from ansgarbecker, 7 years ago, revision 9.4.0.5135
Escape quotes and stuff in JSON keys and values. See http://www.heidisql.com/forum.php?t=22747
ansgar's profile image ansgar posted 7 years ago Permalink

Fixed in r5135

[expired user #10323]'s profile image [expired user #10323] posted 7 years ago Permalink

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's profile image kalvaro posted 7 years ago Permalink

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 :-?

[expired user #10323]'s profile image [expired user #10323] posted 7 years ago Permalink

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's profile image kalvaro posted 7 years ago Permalink

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).

Code modification/commit cdea092 from ansgarbecker, 7 years ago, revision 9.4.0.5137
Don't encode html entities but escape quotes in JSON grid export. See http://www.heidisql.com/forum.php?t=22747#p22783
ansgar's profile image ansgar posted 7 years ago Permalink

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

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