How do I convert a string to and from JSON with escaped/special characters using DBXJSON?

前端 未结 3 1974
长发绾君心
长发绾君心 2020-12-28 08:54

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

3条回答
  •  梦谈多话
    2020-12-28 08:58

    We just ran into this lovely problem, where our backslashes weren't being escaped (but our double quotes were, apparently lol)...

    The solution was to stop using TJSONObject.ToString(), and use TJSONObject.ToJSON() instead. This gives you the correctly escaped string, as opposed to the human readable format that ToString() returns.

    Hope this helps someone :)

提交回复
热议问题