Search in sources :

Example 11 with JSONReader

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

the class LongFieldTest_2_stream method test_max.

public void test_max() throws Exception {
    V0 v = new V0();
    v.setValue(Long.MIN_VALUE);
    String text = JSON.toJSONString(v);
    JSONReader reader = new JSONReader(new StringReader(text));
    V0 v1 = reader.readObject(V0.class);
    Assert.assertEquals(v1.getValue(), v.getValue());
}
Also used : StringReader(java.io.StringReader) JSONReader(com.alibaba.fastjson.JSONReader)

Example 12 with JSONReader

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

the class LongFieldTest_2_stream method test_min.

public void test_min() throws Exception {
    V0 v = new V0();
    v.setValue(Long.MIN_VALUE);
    String text = JSON.toJSONString(v);
    JSONReader reader = new JSONReader(new StringReader(text));
    V0 v1 = reader.readObject(V0.class);
    Assert.assertEquals(v1.getValue(), v.getValue());
    reader.close();
}
Also used : StringReader(java.io.StringReader) JSONReader(com.alibaba.fastjson.JSONReader)

Example 13 with JSONReader

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

the class LongFieldTest_2_stream method test_max_array.

public void test_max_array() throws Exception {
    V0 v = new V0();
    v.setValue(Long.MIN_VALUE);
    String text = JSON.toJSONString(v, SerializerFeature.BeanToArray);
    JSONReader reader = new JSONReader(new StringReader(text), Feature.SupportArrayToBean);
    V0 v1 = reader.readObject(V0.class);
    Assert.assertEquals(v1.getValue(), v.getValue());
}
Also used : StringReader(java.io.StringReader) JSONReader(com.alibaba.fastjson.JSONReader)

Example 14 with JSONReader

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

the class LongFieldTest_2_stream method test_min_array.

public void test_min_array() throws Exception {
    V0 v = new V0();
    v.setValue(Long.MIN_VALUE);
    String text = JSON.toJSONString(v, SerializerFeature.BeanToArray);
    JSONReader reader = new JSONReader(new StringReader(text), Feature.SupportArrayToBean);
    V0 v1 = reader.readObject(V0.class);
    Assert.assertEquals(v1.getValue(), v.getValue());
}
Also used : StringReader(java.io.StringReader) JSONReader(com.alibaba.fastjson.JSONReader)

Example 15 with JSONReader

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

the class StringFieldTest_special method test_special.

public void test_special() throws Exception {
    Model model = new Model();
    model.name = "a\\bc";
    String text = JSON.toJSONString(model);
    Assert.assertEquals("{\"name\":\"a\\\\bc\"}", text);
    JSONReader reader = new JSONReader(new StringReader(text));
    Model model2 = reader.readObject(Model.class);
    Assert.assertEquals(model.name, model2.name);
    reader.close();
}
Also used : StringReader(java.io.StringReader) JSONReader(com.alibaba.fastjson.JSONReader)

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