Search in sources :

Example 41 with JSONException

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

the class EnumFieldTest2_private method test_error_nul.

public void test_error_nul() throws Exception {
    Exception error = null;
    try {
        JSONReader read = new JSONReader(new StringReader("[nul"));
        read.config(Feature.SupportArrayToBean, true);
        Model model = read.readObject(Model.class);
        read.readObject(Model.class);
    } catch (JSONException ex) {
        error = ex;
    }
    Assert.assertNotNull(error);
}
Also used : StringReader(java.io.StringReader) JSONException(com.alibaba.fastjson.JSONException) JSONReader(com.alibaba.fastjson.JSONReader) JSONException(com.alibaba.fastjson.JSONException)

Example 42 with JSONException

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

the class EnumFieldTest2_private method test_error_nu.

public void test_error_nu() throws Exception {
    Exception error = null;
    try {
        JSONReader read = new JSONReader(new StringReader("[nu"));
        read.config(Feature.SupportArrayToBean, true);
        Model model = read.readObject(Model.class);
        read.readObject(Model.class);
    } catch (JSONException ex) {
        error = ex;
    }
    Assert.assertNotNull(error);
}
Also used : StringReader(java.io.StringReader) JSONException(com.alibaba.fastjson.JSONException) JSONReader(com.alibaba.fastjson.JSONReader) JSONException(com.alibaba.fastjson.JSONException)

Example 43 with JSONException

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

the class JSONObjectTest3 method test_error_3.

public void test_error_3() throws Exception {
    String text = "{value:'123',big:false}";
    Bean bean = JSON.parseObject(text, Bean.class);
    JSONException error = null;
    try {
        bean.is();
    } catch (JSONException ex) {
        error = ex;
    }
    Assert.assertNotNull(error);
}
Also used : JSONException(com.alibaba.fastjson.JSONException)

Example 44 with JSONException

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

the class JSONObjectTest3 method test_error_8.

public void test_error_8() throws Exception {
    String text = "{value:'123',big:false}";
    Bean bean = JSON.parseObject(text, Bean.class);
    JSONException error = null;
    try {
        bean.xx();
    } catch (JSONException ex) {
        error = ex;
    }
    Assert.assertNotNull(error);
}
Also used : JSONException(com.alibaba.fastjson.JSONException)

Example 45 with JSONException

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

the class Bug_for_issue_537 method test_for_issue_method.

public void test_for_issue_method() throws Exception {
    String text = "{\"value\":2147483649}";
    Exception error = null;
    try {
        JSON.parseObject(text, V2.class);
    } catch (JSONException ex) {
        error = ex;
    }
    Assert.assertNotNull(error);
    Assert.assertTrue(error.getMessage().contains("field : value"));
}
Also used : JSONException(com.alibaba.fastjson.JSONException) 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