Search in sources :

Example 66 with JSONException

use of com.alibaba.fastjson.JSONException in project fastjson by alibaba.

the class DefaultJSONParserTest_comma method test_getInput.

public void test_getInput() {
    String text = "{,,}";
    char[] chars = text.toCharArray();
    DefaultJSONParser parser = new DefaultJSONParser(chars, chars.length, ParserConfig.getGlobalInstance(), 0);
    JSONException error = null;
    try {
        parser.parseObject();
    } catch (JSONException ex) {
        error = ex;
    }
    Assert.assertNotNull(error);
}
Also used : JSONException(com.alibaba.fastjson.JSONException) DefaultJSONParser(com.alibaba.fastjson.parser.DefaultJSONParser)

Example 67 with JSONException

use of com.alibaba.fastjson.JSONException in project fastjson by alibaba.

the class DefaultJSONParserTest_error method test_error_2.

public void test_error_2() {
    String text = "{\"obj\":[]]}";
    char[] chars = text.toCharArray();
    DefaultJSONParser parser = new DefaultJSONParser(chars, chars.length, ParserConfig.getGlobalInstance(), 0);
    JSONException error = null;
    try {
        parser.parseObject();
    } catch (JSONException ex) {
        error = ex;
    }
    Assert.assertNotNull(error);
}
Also used : JSONException(com.alibaba.fastjson.JSONException) DefaultJSONParser(com.alibaba.fastjson.parser.DefaultJSONParser)

Example 68 with JSONException

use of com.alibaba.fastjson.JSONException in project fastjson by alibaba.

the class JSONScannerTest_colon method test_7.

public void test_7() throws Exception {
    JSONException error = null;
    try {
        JSONScanner lexer = new JSONScanner("true");
        lexer.nextTokenWithColon();
    } catch (JSONException e) {
        error = e;
    }
    Assert.assertNotNull(error);
}
Also used : JSONScanner(com.alibaba.fastjson.parser.JSONScanner) JSONException(com.alibaba.fastjson.JSONException)

Example 69 with JSONException

use of com.alibaba.fastjson.JSONException in project fastjson by alibaba.

the class JSONScannerTest_false method test_scan_false_5.

public void test_scan_false_5() throws Exception {
    JSONException error = null;
    try {
        JSONScanner lexer = new JSONScanner("falsz");
        lexer.scanFalse();
    } catch (JSONException e) {
        error = e;
    }
    Assert.assertNotNull(error);
}
Also used : JSONScanner(com.alibaba.fastjson.parser.JSONScanner) JSONException(com.alibaba.fastjson.JSONException)

Example 70 with JSONException

use of com.alibaba.fastjson.JSONException in project fastjson by alibaba.

the class JSONScannerTest_scanFieldFloat method test_error_6.

public void test_error_6() throws Exception {
    JSONException error = null;
    try {
        String text = "{\"value\":3.2]";
        JSON.parseObject(text, VO.class);
    } catch (JSONException ex) {
        error = ex;
    }
    Assert.assertNotNull(error);
}
Also used : JSONException(com.alibaba.fastjson.JSONException)

Aggregations

JSONException (com.alibaba.fastjson.JSONException)484 JSONReader (com.alibaba.fastjson.JSONReader)83 StringReader (java.io.StringReader)83 JSONScanner (com.alibaba.fastjson.parser.JSONScanner)37 JSONObject (com.alibaba.fastjson.JSONObject)28 DefaultJSONParser (com.alibaba.fastjson.parser.DefaultJSONParser)26 Map (java.util.Map)26 JSONLexer (com.alibaba.fastjson.parser.JSONLexer)17 IOException (java.io.IOException)17 ParseException (java.text.ParseException)8 ParserConfig (com.alibaba.fastjson.parser.ParserConfig)7 FieldInfo (com.alibaba.fastjson.util.FieldInfo)7 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)7 JSONType (com.alibaba.fastjson.annotation.JSONType)6 JSONSerializer (com.alibaba.fastjson.serializer.JSONSerializer)6 Gson (com.google.gson.Gson)6 AccessibleObject (java.lang.reflect.AccessibleObject)6 Type (java.lang.reflect.Type)6 JSONField (com.alibaba.fastjson.annotation.JSONField)5 Point (java.awt.Point)5