I'm having trouble converting a string with escaped characters to and from a TJsonString. (I'm using Delphi XE 2, Update 4, Hotfix 1).
NOTE: I am familiar with the SuperObject, but my requirements are to use the DBXJSON unit.
It looks like the TJSONString is not correctly escaped when returning the JSON representation via the ToString() method.
What (if anything) am I doing wrong and how do I correctly convert a string with special characters to/from its correct JSON representation?
Perhaps I missed something, but none of the following Q&As seemed to address this directly:
- Delphi decode json/utf8 escaped text
- Delphi JSON library for XE2 available for object serialization
- Delphi: JSON array
- How to parse nested JSON object in Delphi XE2?
- Nested json object deserializing using Delphi 2012
EDIT:
As it turns out, the examples below were indeed working as expected.
What wasn't clear to me was that when creating a TJSONString via it's constructor and adding it to a TJSONObject, the ToString() method will return an escaped representation. However, after parsing a TJSONObject, the ToString() method will returned the un-escaped representation.