spark85 / json-path

Automatically exported from code.google.com/p/json-path
0 stars 0 forks source link

JSON with escape characters cannot be parsed #32

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
Try to parse JSON like:
{"text" : "skill: \"Heuristic Evaluation\"", "country" : ""}

What is the expected output? What do you see instead?
I'm getting the error:
com.jayway.jsonpath.InvalidJsonException: Unexpected token euristic 
Evaluation"",
            "country" at position ...
However the provided JSON is completely valid and should be parsed well.

What version of the product are you using? On what operating system?
0.8.1

Please provide any additional information below.

Original issue reported on code.google.com by gamler.m...@tut.by on 31 May 2013 at 12:21

GoogleCodeExporter commented 9 years ago
You must escape the backslashes.

Check this tread out 
http://stackoverflow.com/questions/3020094/how-should-i-escape-strings-in-json

String json = "{\"text\" : \"skill: \\\"Heuristic Evaluation\\\"\", \"country\" 
: \"\"}";
assertEquals("skill: \"Heuristic Evaluation\"", JsonPath.read(json, "$.text"));

Original comment by kalle.st...@gmail.com on 21 Aug 2013 at 7:46