Search in sources :

Example 56 with JSONException

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

the class DateParserTest method test_date_error_0.

public void test_date_error_0() throws Exception {
    JSONException error = null;
    try {
        DefaultJSONParser parser = new DefaultJSONParser("true");
        parser.parseObject(java.util.Date.class);
        parser.close();
    } catch (JSONException e) {
        error = e;
    }
    Assert.assertNotNull(error);
}
Also used : JSONException(com.alibaba.fastjson.JSONException) DefaultJSONParser(com.alibaba.fastjson.parser.DefaultJSONParser)

Example 57 with JSONException

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

the class DefaultExtJSONParserTest_0 method test_error_2.

public void test_error_2() throws Exception {
    JSONException error = null;
    try {
        DefaultJSONParser parser = new DefaultJSONParser("{\"errorValue\":33}");
        parser.parseArray(User.class);
    } catch (JSONException e) {
        error = e;
    }
    Assert.assertNotNull(error);
}
Also used : JSONException(com.alibaba.fastjson.JSONException) DefaultJSONParser(com.alibaba.fastjson.parser.DefaultJSONParser)

Example 58 with JSONException

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

the class DefaultExtJSONParserTest_0 method test_error_3.

public void test_error_3() throws Exception {
    JSONException error = null;
    try {
        DefaultJSONParser parser = new DefaultJSONParser("{\"age\"33}");
        parser.parseArray(User.class);
    } catch (JSONException e) {
        error = e;
    }
    Assert.assertNotNull(error);
}
Also used : JSONException(com.alibaba.fastjson.JSONException) DefaultJSONParser(com.alibaba.fastjson.parser.DefaultJSONParser)

Example 59 with JSONException

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

the class DefaultExtJSONParserTest_2 method test_error_3.

public void test_error_3() throws Exception {
    JSONException error = null;
    try {
        DefaultJSONParser parser = new DefaultJSONParser("{");
        parser.config(Feature.AllowUnQuotedFieldNames, true);
        parser.parseObject(A.class);
    } catch (JSONException e) {
        error = e;
    }
    Assert.assertNotNull(error);
}
Also used : JSONException(com.alibaba.fastjson.JSONException) DefaultJSONParser(com.alibaba.fastjson.parser.DefaultJSONParser)

Example 60 with JSONException

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

the class DefaultExtJSONParserTest_2 method test_error_5.

public void test_error_5() throws Exception {
    JSONException error = null;
    try {
        DefaultJSONParser parser = new DefaultJSONParser("{a:3}");
        parser.config(Feature.AllowUnQuotedFieldNames, false);
        parser.parseObject(A.class);
    } catch (JSONException e) {
        error = e;
    }
    Assert.assertNotNull(error);
}
Also used : JSONException(com.alibaba.fastjson.JSONException) DefaultJSONParser(com.alibaba.fastjson.parser.DefaultJSONParser)

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