Package com.alibaba.json.bvt.parser.stream

Source Code of com.alibaba.json.bvt.parser.stream.JSONReader_obj$VO

package com.alibaba.json.bvt.parser.stream;

import java.io.StringReader;

import junit.framework.TestCase;

import org.junit.Assert;

import com.alibaba.fastjson.JSONReader;

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());

        reader.endArray();

        reader.close();
    }

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

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

        Assert.assertEquals(123, vo.getId());

        reader.close();
    }

    public static class VO {

        private int id;

        public int getId() {
            return id;
        }

        public void setId(int id) {
            this.id = id;
        }

    }
}
TOP

Related Classes of com.alibaba.json.bvt.parser.stream.JSONReader_obj$VO

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.