Package com.alibaba.fastjson

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


    }

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

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

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

        reader.close();
    }
View Full Code Here


            for (int i = 0; i < 8180; ++i) {
                buf.append('A');
            }
            buf.append("\"}");
            JSONReader reader = new JSONReader(new StringReader(buf.toString()));
            reader.readObject();
            reader.close();
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
View Full Code Here

public class JSONReaderScannerTest_enum extends TestCase {

    public void test_e() throws Exception {
        JSONReader reader = new JSONReader(new StringReader("{type:'AA'}"));
        VO vo2 = reader.readObject(VO.class);
        Assert.assertEquals(Type.AA, vo2.getType());
        reader.close();
    }

    public static class VO {
View Full Code Here

            for (int i = 0; i < 8180; ++i) {
                buf.append('A');
            }
            buf.append("\\t");
            JSONReader reader = new JSONReader(new MyReader(buf.toString()));
            reader.readObject();
            reader.close();
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
View Full Code Here

public class JSONReaderScannerTest_jsonobject extends TestCase {

    public void test_e() throws Exception {
        JSONReader reader = new JSONReader(new StringReader("{\"type\\t\":'AA'}"));
        JSONObject vo = new JSONObject();
        reader.readObject(vo);
        Assert.assertEquals("AA", vo.get("type\t"));
        reader.close();
    }

    public static class VO {
View Full Code Here

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

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

        int count = 0;
        while (reader.hasNext()) {
            reader.readObject();
            count++;
        }
        Assert.assertEquals(10, count);

        reader.endArray();
View Full Code Here

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

        int count = 0;
        while (reader.hasNext()) {
            reader.readObject();
            count++;
        }
        Assert.assertEquals(10, count);

        reader.endArray();
View Full Code Here

        reader.startObject();

        int count = 0;
        while (reader.hasNext()) {
            String key = (String) reader.readObject();
            String value = reader.readString();
            count++;
        }
        Assert.assertEquals(10, count);
View Full Code Here

        reader.startObject();

        int count = 0;
        while (reader.hasNext()) {
            String key = (String) reader.readObject();
            Long value = reader.readLong();
            count++;
        }
        Assert.assertEquals(10, count);
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.