Xojo.Data.ParseJSON question. Escaping within JSON data

Hi All,

Something unexpected is happening. I have a JSON, this one for example: { “fruit”: “App
le” } and I load it into a Dictionary by using the ParseJSON function. The unexpected fact is that when I read back the result the data has been altered. Code of a full example below (add it to any button on any window to run)

--------------------------------CODE BEGIN
Dim json As Text
json = “{ ““fruit””: ““App
le”” }”

Dim names As Xojo.Core.Dictionary
names = Xojo.Data.ParseJSON(json)

for each entry as Xojo.Core.DictionaryEntry in names
msgbox(entry.value)
next
--------------------------------CODE END

The Msgbox in this case returns

        App
        le

I was expecting to see

        App\

le

Is there a way to prevent ParseJSON to do this? If not, what are the cases when I should expect the function to interpret the value of the json file?

Thanks,
Fabio


is the encoding that JSON uses to indicate a carriage return. If you want it to appear as
, you would need to escape the slash as well… “App\
le”

Thank you Greg. So am looking now at this page: https://www.freeformatter.com/json-escape.html
ParseJSON should act upon all of these:

Backspace is replaced with \\b
Form feed is replaced with \\f
Newline is replaced with \

Carriage return is replaced with \\r
Tab is replaced with \\t
Double quote is replaced with \"
Backslash is replaced with \\\\

Is there a place where I can read what the ParseJSON function will actually reconize as encoding?

[quote=434234:@Fabio Lichinchi]Thank you Greg. So am looking now at this page: https://www.freeformatter.com/json-escape.html
ParseJSON should act upon all of these:

Backspace is replaced with \\b
Form feed is replaced with \\f
Newline is replaced with \

Carriage return is replaced with \\r
Tab is replaced with \\t
Double quote is replaced with \"
Backslash is replaced with \\\\

Is there a place where I can read what the ParseJSON function will actually reconize as encoding?[/quote]
It should recognize all of them. I see I was incorrect though…
is a newline not a carriage return.

Didn’t event notice :slight_smile:

Thank you!