I have a piece of JSON in UTF-8 that looks like this in Google Chrome (without the new lines):

{"_links": {"self": {"href": "http://bla:8888/1/2/3/2257487e4a750cab"}, 
"it\u0119m": [{"href": "http://bla:8888/1/2/4/8f4fea003fe4c7fb284801d082de34a6"},
{"href": "http://bla:8888/1/2/4/c1213dd511c5427256c81f222e942c28"}]}}

First I remove all spaces for DBXJSON to work. Then I parse and print it, with this result:

{"_links":{"self":{"href":"http://bla:8888/1/2/3/2257487e4a750cab"},
"itęm":[{"href":"http://bla:8888/1/2/4/8f4fea003fe4c7fb284801d082de34a6"},
{"href":"http://bla:8888/1/2/4/c1213dd511c5427256c81f222e942c28"}]}}

That's how I want it, except for the need to remove spaces.

If I use the same JSON string as input to dwsJSON, interesting things happen:

{"_links":{"self":{"href":"http://bla:8888/1/2/3/2257487e4a750cab"},
"it\u0119m":[{"href":"4a6p://bla:8888/1/2/4/8f4fea003fe4c7fb284801d082de3/1."}
{"href":"c28p://bla:8888/1/2/4/c1213dd511c5427256c81f222e942\n\u0000\u0000"}]}}

Unicode literals are not interpreted, \u0000 is all over the place in a bigger file and generally some kind of garbling is going on.

What causes this and where should I look to fix it? TdwsJSONValue.ParseString takes a UnicodeString and my input is a String, but I'm not sure how that matters (kind of lost with all Delphi String types).

有帮助吗?

解决方案

Because of earlier struggles with unicode, I really thought I was doing something wrong. But this simply was a bug. No such problem anymore in SVN trunk at this time.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top