mathewdenis / json-smart

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

JSONParser of json-smart is not throwing exception for invalid json string #46

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create JSONParser with mode as RFC4627
2. try to parse string "{ \"param1\'\': value1, \"param2\": \"value2\" }" which 
invalid format

What is the expected output? What do you see instead?
It should throw exception, instead it's getting parsed as valid

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

Please provide any additional information below.

Original issue reported on code.google.com by arunoda...@gmail.com on 10 Jul 2014 at 10:51

GoogleCodeExporter commented 9 years ago
OS is WINDOWS7 64bit

Original comment by arunoda...@gmail.com on 10 Jul 2014 at 10:54

GoogleCodeExporter commented 9 years ago
{ "param1:"sample"": "value1", "param2": "value2" }

Even this is taken as valid but  actually invalid

Original comment by arunoda...@gmail.com on 10 Jul 2014 at 11:37

GoogleCodeExporter commented 9 years ago
Tested with the curent version 2.0 and 1.3, an exception are throws.

public class TestIssue46 extends TestCase {
    public void testEmptyStrict() throws Exception {
        String s;
        s = "{ \"param1:\"sample\"\": \"value1\", \"param2\": \"value2\" }";
        s = "{ \"param1\'\': value1, \"param2\": \"value2\" }";
        JSONObject o = null;
        try {
            o = (JSONObject) JSONValue.parseStrict(s);
        } catch (Exception e) {
            // should be invalid
        }
        assertEquals(o, null);
    }
}

Original comment by uriel.chemouni on 15 Jul 2014 at 11:30

GoogleCodeExporter commented 9 years ago
{ \"param1\": \"value1\", \"param2\": \"value2\" }\\\\\\

But still this does not throw any exception. This is taken as valid.

Original comment by arunoda...@gmail.com on 16 Jul 2014 at 11:03