Package com.alibaba.fastjson

Examples of com.alibaba.fastjson.JSONReader.startArray()


public class JSONReader_map extends TestCase {

    public void test_array() throws Exception {
        JSONReader reader = new JSONReader(new StringReader("[{\"id\":123}]"));

        reader.startArray();

        Map<String, Object> map = new HashMap<String, Object>();
        reader.readObject(map);

        Assert.assertEquals(123, map.get("id"));
View Full Code Here


        ;

        JSONReader reader = new JSONReader(new StringReader("[{}]"));
        reader.config(Feature.AllowArbitraryCommas, true);

        reader.startArray();

        Object context = field.get(reader);
        Field stateField = context.getClass().getDeclaredField("state");
        stateField.setAccessible(true);
        stateField.set(context, -1);
View Full Code Here

public class JSONReader_obj_2 extends TestCase {

    public void test_array() throws Exception {
        JSONReader reader = new JSONReader(new StringReader("[{\"id\":123}]"));

        reader.startArray();

        VO vo = reader.readObject(VO.class);

        Assert.assertEquals(123, vo.getId());
View Full Code Here

        reader.startObject();
       
        String key = reader.readString();
       
        Assert.assertEquals("rec", key);
        reader.startArray();
       
        List<KeyValue> list = new ArrayList<KeyValue>();
        while(reader.hasNext()) {
            KeyValue keyValue = reader.readObject(KeyValue.class);
            list.add(keyValue);
View Full Code Here

    String text = "[{},{},{},{},{} ,{},{},{},{},{}]";

    public void test_read() throws Exception {

        JSONReader reader = new JSONReader(new StringReader(text));
        reader.startArray();

        int count = 0;
        while (reader.hasNext()) {
            reader.readObject();
            count++;
View Full Code Here

        reader.close();
    }

    public void test_read_1() throws Exception {
        JSONReader reader = new JSONReader(new JSONScanner(text));
        reader.startArray();

        int count = 0;
        while (reader.hasNext()) {
            reader.readObject();
            count++;
View Full Code Here

        reader.close();
    }
   
    public void test_read_3() throws Exception {
        JSONReader reader = new JSONReader(new JSONScanner(text));
        reader.startArray();

       
       
        Assert.assertTrue(reader.hasNext());
        reader.startObject();
View Full Code Here

public class JSONReader_obj extends TestCase {

    public void test_array() throws Exception {
        JSONReader reader = new JSONReader(new StringReader("[{\"id\":123}]"));

        reader.startArray();

        VO vo = new VO();
        reader.readObject(vo);

        Assert.assertEquals(123, vo.getId());
View Full Code Here

public class JSONReader_array extends TestCase {

    public void test_array() throws Exception {
        JSONReader reader = new JSONReader(new StringReader("[[],[],3,null,{\"name\":\"jobs\"},{\"id\":123},{\"id\":1},{\"id\":2}]"));
        reader.startArray();

        JSONArray first = (JSONArray) reader.readObject();
        JSONArray second = (JSONArray) reader.readObject();

        Assert.assertNotNull(first);
View Full Code Here

        ;

        JSONReader reader = new JSONReader(new StringReader("[{}]"));
        reader.config(Feature.AllowArbitraryCommas, true);

        reader.startArray();

        context = field.get(reader);
        stateField = context.getClass().getDeclaredField("state");
        stateField.setAccessible(true);
       
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.