Package com.alibaba.fastjson.parser

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


        Assert.assertEquals(0, values.length);
    }

    public void test_18() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("null");
        parser.config(Feature.AllowISO8601DateFormat, false);
        List<Integer> list = (List<Integer>) parser.parseArrayWithType(new TypeReference<List<Integer>>() {
        }.getType());
        Assert.assertEquals(null, list);
    }
View Full Code Here


        Assert.assertEquals(null, list);
    }

    public void test_error_var() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("[1,2,null }");
        parser.config(Feature.AllowISO8601DateFormat, false);

        Exception error = null;
        try {
            Object[] array = parser.parseArray(new Type[] { Integer[].class });
        } catch (Exception ex) {
View Full Code Here

    }

    public void test_error_3() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("[1,null }");
        ArrayList list = new ArrayList();
        parser.config(Feature.AllowISO8601DateFormat, false);

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

        Assert.assertNotNull(error);
    }

    public void test_error_4() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("[1,null }");
        parser.config(Feature.AllowISO8601DateFormat, false);

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

    }

    public void test_error_5() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("[1,null }");
        ArrayList list = new ArrayList();
        parser.config(Feature.AllowISO8601DateFormat, false);

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

        Assert.assertNotNull(error);
    }

    public void test_error_6() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("{1,null }");
        parser.config(Feature.AllowISO8601DateFormat, false);

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

        Assert.assertNotNull(error);
    }

    public void test_error_7() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("{1}");
        parser.config(Feature.AllowISO8601DateFormat, false);

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

        Assert.assertNotNull(error);
    }

    public void test_error_8() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("[1,2,3 4]");
        parser.config(Feature.AllowISO8601DateFormat, false);

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

        List<?> res = Arrays.asList(1, 2, 3);
        String[] tests = { "[1,2,3]", "[1,,2,3]", "[1,2,,,3]", "[1 2,,,3]", "[1 2 3]", "[1, 2, 3,,]", "[,,1, 2, 3,,]", };

        for (String t : tests) {
            DefaultExtJSONParser ext = new DefaultExtJSONParser(t);
            ext.config(Feature.AllowArbitraryCommas, true);
            List<Object> extRes = ext.parseArray(Object.class);
            Assert.assertEquals(res, extRes);

            DefaultJSONParser basic = new DefaultJSONParser(t);
            basic.config(Feature.AllowArbitraryCommas, true);
View Full Code Here

        String[] tests = { "{ 'a':1, 'b':2, 'c':3 }", "{ 'a':1,,'b':2, 'c':3 }", "{,'a':1, 'b':2, 'c':3 }", "{'a':1, 'b':2, 'c':3,,}",
                "{,,'a':1,,,,'b':2,'c':3,,,,,}", };

        for (String t : tests) {
            DefaultExtJSONParser ext = new DefaultExtJSONParser(t);
            ext.config(Feature.AllowArbitraryCommas, true);

            JSONObject extRes = ext.parseObject();
            Assert.assertEquals(res.toString(), extRes.toString());

            DefaultJSONParser basic = new DefaultJSONParser(t);
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.