Package com.alibaba.fastjson.parser

Examples of com.alibaba.fastjson.parser.DefaultExtJSONParser.parseArray()


    }

    public <T> Collection<T> decodeArray(String text, Class<T> clazz) throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser(text, config);
        parser.config(Feature.DisableCircularReferenceDetect, true);
        return parser.parseArray(clazz);
    }

    public final Object decodeObject(String text) {
        DefaultJSONParser parser = new DefaultJSONParser(text, config);
        parser.config(Feature.DisableCircularReferenceDetect, true);
View Full Code Here


        parser.config(Feature.AllowArbitraryCommas, false);
        List<String> list = new ArrayList<String>();

        Exception error = null;
        try {
            parser.parseArray(String.class, list);
        } catch (JSONException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
View Full Code Here

    public void test_parseArray() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("[1]");
        parser.config(Feature.AllowArbitraryCommas, false);
        List<String> list = new ArrayList<String>();
        parser.parseArray(String.class, list);
        Assert.assertEquals(1, list.size());
    }

    public void test_parseArray_error() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("[1,2}");
View Full Code Here

    public void test_1() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("['1','2']");
        parser.config(Feature.AllowISO8601DateFormat, false);
        List<Object> list = new ArrayList<Object>();
        parser.parseArray(Integer.class, list);
        Assert.assertEquals(new Integer(1), list.get(0));
        Assert.assertEquals(new Integer(2), list.get(1));
    }

    public void test_error_0() throws Exception {
View Full Code Here

        parser.config(Feature.AllowISO8601DateFormat, false);

        Exception error = null;
        try {
            List<Object> list = new ArrayList<Object>();
            parser.parseArray(Integer.class, list);
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
View Full Code Here

        parser.config(Feature.AllowISO8601DateFormat, false);

        List list = new ArrayList();
        Exception error = null;
        try {
            parser.parseArray(list);
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
View Full Code Here

        parser.config(Feature.AllowISO8601DateFormat, false);

        List list = new ArrayList();
        Exception error = null;
        try {
            parser.parseArray(list);
            parser.close();
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
View Full Code Here

        DefaultExtJSONParser parser = new DefaultExtJSONParser("['1','2'}");
        parser.config(Feature.AllowISO8601DateFormat, false);

        Exception error = null;
        try {
            parser.parseArray(new Type[] {});
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
View Full Code Here

    public void test_error_5() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("[]");
        parser.config(Feature.AllowISO8601DateFormat, false);

        Assert.assertEquals(1, parser.parseArray(new Type[] { Integer[].class }).length);
    }
   
    public void test_error_6() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("['1' 1 '2'}");
        parser.config(Feature.AllowISO8601DateFormat, false);
View Full Code Here

        DefaultExtJSONParser parser = new DefaultExtJSONParser("['1' 1 '2'}");
        parser.config(Feature.AllowISO8601DateFormat, false);

        Exception error = null;
        try {
            parser.parseArray(new Type[] {Integer.class});
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
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.