pvdung / quick-json

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

Backslashes should have to be escaped to be included in data #6

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
I'm trying to specify string random data for a value which will be delimited by 
double quotes and which might include backslashes and/or double quotes.  I can 
escape a double quote very easily but it appears that I do not have to escape 
backslashes.  The problem with not being able to escape backslashes is that you 
can't end a string with a backslash because the next character is a quote and 
the parser believe the backslash is escaping the closing quote.

I will attach a sample JSON file.

What is the expected output? What do you see instead?

When I try to parse the JSON, I get:

And get the following when I try to parse it:

com.json.exceptions.JSONParsingException: 
@Key-Heirarchy::root/data[0]/   @Key::varcharData   COMMA or } is expected. but 
found b...@Position::716
    at com.json.utils.JSONUtility.handleFailure(JSONUtility.java:124)
    at com.json.parsers.JSONParser.stringLiteralTemplate(JSONParser.java:574)
    at com.json.parsers.JSONParser.nonValidatingValueTemplate(JSONParser.java:698)
    at com.json.parsers.JSONParser.parseValue(JSONParser.java:377)
    at com.json.parsers.JSONParser.parseKeysValues(JSONParser.java:254)
    at com.json.parsers.JSONParser.parseJsonBody(JSONParser.java:232)
    at com.json.parsers.JSONParser.jsonArrayTemplate(JSONParser.java:433)
    at com.json.parsers.JSONParser.parseValue(JSONParser.java:368)
    at com.json.parsers.JSONParser.parseKeysValues(JSONParser.java:254)
    at com.json.parsers.JSONParser.parseJsonBody(JSONParser.java:232)
    at com.json.parsers.JSONParser.parseJsonBlock(JSONParser.java:212)
    at com.json.parsers.JSONParser.parseJson(JSONParser.java:139)
    at com.json.parsers.JSONParser.parseJson(JSONParser.java:87)

I should not get an exception

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

I'm using quick-json-1.0.2.3 on Ubuntu precise (12.04.2 LTS) with:

java version "1.7.0_25"
OpenJDK Runtime Environment (IcedTea 2.3.10) (7u25-2.3.10-1ubuntu0.12.04.2)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)

Please provide any additional information below.

Original issue reported on code.google.com by brunored...@gmail.com on 24 Jul 2013 at 3:24

Attachments:

GoogleCodeExporter commented 9 years ago
Should be fixed in https://code.google.com/p/quick-json/issues/detail?id=11

Original comment by noack.mi...@googlemail.com on 23 Oct 2014 at 3:36