Search in sources :

Example 1 with VO

use of com.alibaba.json.bvt.writeAsArray.WriteAsArray_int_public.VO in project fastjson by alibaba.

the class WriteAsArray_long_public method test_2.

public void test_2() throws Exception {
    String text = "[-123 ,\"wenshao\"]";
    VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
    Assert.assertEquals(-123, vo2.getId());
    Assert.assertEquals("wenshao", vo2.getName());
}
Also used : VO(com.alibaba.json.bvt.writeAsArray.WriteAsArray_int_public.VO)

Example 2 with VO

use of com.alibaba.json.bvt.writeAsArray.WriteAsArray_int_public.VO in project fastjson by alibaba.

the class WriteAsArray_long_public method test_0.

public void test_0() throws Exception {
    VO vo = new VO();
    vo.setId(123);
    vo.setName("wenshao");
    String text = JSON.toJSONString(vo, SerializerFeature.BeanToArray);
    Assert.assertEquals("[123,\"wenshao\"]", text);
    VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
    Assert.assertEquals(vo.getId(), vo2.getId());
    Assert.assertEquals(vo.getName(), vo2.getName());
}
Also used : VO(com.alibaba.json.bvt.writeAsArray.WriteAsArray_int_public.VO)

Example 3 with VO

use of com.alibaba.json.bvt.writeAsArray.WriteAsArray_int_public.VO in project fastjson by alibaba.

the class WriteAsArray_long_public method test_1.

public void test_1() throws Exception {
    String text = "[123 ,\"wenshao\"]";
    VO vo2 = JSON.parseObject(text, VO.class, Feature.SupportArrayToBean);
    Assert.assertEquals(123, vo2.getId());
    Assert.assertEquals("wenshao", vo2.getName());
}
Also used : VO(com.alibaba.json.bvt.writeAsArray.WriteAsArray_int_public.VO)

Example 4 with VO

use of com.alibaba.json.bvt.writeAsArray.WriteAsArray_int_public.VO in project fastjson by alibaba.

the class WriteAsArray_long_public method test_2_stream.

public void test_2_stream() throws Exception {
    String text = "[-123 ,\"wenshao\"]";
    JSONReader reader = new JSONReader(new StringReader(text), Feature.SupportArrayToBean);
    VO vo2 = reader.readObject(VO.class);
    Assert.assertEquals(-123, vo2.getId());
    Assert.assertEquals("wenshao", vo2.getName());
}
Also used : StringReader(java.io.StringReader) VO(com.alibaba.json.bvt.writeAsArray.WriteAsArray_int_public.VO) JSONReader(com.alibaba.fastjson.JSONReader)

Example 5 with VO

use of com.alibaba.json.bvt.writeAsArray.WriteAsArray_int_public.VO in project fastjson by alibaba.

the class WriteAsArray_long_public method test_1_stream.

public void test_1_stream() throws Exception {
    String text = "[123 ,\"wenshao\"]";
    JSONReader reader = new JSONReader(new StringReader(text), Feature.SupportArrayToBean);
    VO vo2 = reader.readObject(VO.class);
    Assert.assertEquals(123, vo2.getId());
    Assert.assertEquals("wenshao", vo2.getName());
}
Also used : StringReader(java.io.StringReader) VO(com.alibaba.json.bvt.writeAsArray.WriteAsArray_int_public.VO) JSONReader(com.alibaba.fastjson.JSONReader)

Aggregations

VO (com.alibaba.json.bvt.writeAsArray.WriteAsArray_int_public.VO)5 JSONReader (com.alibaba.fastjson.JSONReader)2 StringReader (java.io.StringReader)2