Search in sources :

Example 61 with JSONReader

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

the class ReaderBooleanFieldTest method test_bool_error_f1.

public void test_bool_error_f1() throws Exception {
    Exception error = null;
    try {
        JSONReader reader = new JSONReader(new StringReader("{\"value\":fa}"));
        reader.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 62 with JSONReader

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

the class ReaderIntFieldTest method test_int_error_1.

public void test_int_error_1() throws Exception {
    Exception error = null;
    try {
        JSONReader reader = new JSONReader(new StringReader("{\"value\":2147483648}"));
        reader.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 63 with JSONReader

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

the class ReaderIntFieldTest method test_int_error_1_x.

public void test_int_error_1_x() throws Exception {
    Exception error = null;
    try {
        JSONReader reader = new JSONReader(new StringReader("{\"value\":9223372036854775808}"));
        reader.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 64 with JSONReader

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

the class ReaderIntFieldTest method test_int_error_end.

public void test_int_error_end() throws Exception {
    Exception error = null;
    try {
        JSONReader reader = new JSONReader(new StringReader("{\"value\":1001,\"value2\":-2001["));
        reader.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 65 with JSONReader

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

the class ReaderIntFieldTest method test_int_error_0.

public void test_int_error_0() throws Exception {
    Exception error = null;
    try {
        JSONReader reader = new JSONReader(new StringReader("{\"value\":1.A}"));
        reader.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)

Aggregations

JSONReader (com.alibaba.fastjson.JSONReader)215 StringReader (java.io.StringReader)195 JSONException (com.alibaba.fastjson.JSONException)83 Map (java.util.Map)30 JSONScanner (com.alibaba.fastjson.parser.JSONScanner)11 IOException (java.io.IOException)5 JSONObject (com.alibaba.fastjson.JSONObject)4 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 JSONWriter (com.alibaba.fastjson.JSONWriter)3 File (java.io.File)3 InputStream (java.io.InputStream)3 InputStreamReader (java.io.InputStreamReader)3 JSONArray (com.alibaba.fastjson.JSONArray)2 TypeReference (com.alibaba.fastjson.TypeReference)2 VO (com.alibaba.json.bvt.writeAsArray.WriteAsArray_int_public.VO)2 StringWriter (java.io.StringWriter)2 Field (java.lang.reflect.Field)2 Random (java.util.Random)2 Model (com.alibaba.json.bvt.LongFieldTest_3_stream.Model)1