Package com.alibaba.fastjson.parser

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


        Assert.assertEquals("[1, 2, 3]", list.toString());
    }

    public void test_1() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("[1,2,3]");
        parser.config(Feature.AllowArbitraryCommas, true);
        List list = new ArrayList();
        parser.parseArray(int.class, list);
        Assert.assertEquals("[1, 2, 3]", list.toString());
    }
View Full Code Here


        Assert.assertEquals("[1, 2, 3]", list.toString());
    }

    public void test_2() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("['1','2','3']");
        parser.config(Feature.AllowArbitraryCommas, true);
        List list = new ArrayList();
        parser.parseArray(String.class, list);
        Assert.assertEquals("[1, 2, 3]", list.toString());
        Assert.assertEquals("1", list.get(0));
    }
View Full Code Here

        Assert.assertEquals("1", list.get(0));
    }

    public void test_3() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("[1,2,3]");
        parser.config(Feature.AllowArbitraryCommas, true);
        List list = new ArrayList();
        parser.parseArray(BigDecimal.class, list);
        Assert.assertEquals("[1, 2, 3]", list.toString());
        Assert.assertEquals(new BigDecimal("1"), list.get(0));
    }
View Full Code Here

        Assert.assertEquals(new BigDecimal("1"), list.get(0));
    }

    public void test_4() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("[1,2,3,null]");
        parser.config(Feature.AllowArbitraryCommas, true);
        List list = new ArrayList();
        parser.parseArray(BigDecimal.class, list);
        Assert.assertEquals("[1, 2, 3, null]", list.toString());
        Assert.assertEquals(new BigDecimal("1"), list.get(0));
    }
View Full Code Here

        Assert.assertNotNull(error);
    }

    public void test_6() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("[1.2]");
        parser.config(Feature.UseBigDecimal, false);
        ArrayList list = new ArrayList();
        parser.parseArray(list);
        Assert.assertEquals(Double.valueOf(1.2), list.get(0));
    }
View Full Code Here

        Assert.assertEquals(Double.valueOf(1.2), list.get(0));
    }

    public void test_7() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("[\"2011-01-09T13:49:53.254\", \"xxx\", true, false, null, {}]");
        parser.config(Feature.AllowISO8601DateFormat, true);
        ArrayList list = new ArrayList();
        parser.parseArray(list);
        Assert.assertEquals(new Date(1294552193254L), list.get(0));
        Assert.assertEquals("xxx", list.get(1));
        Assert.assertEquals(Boolean.TRUE, list.get(2));
View Full Code Here

        Assert.assertEquals(new JSONObject(), list.get(5));
    }

    public void test_8() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("\"2011-01-09T13:49:53.254\"");
        parser.config(Feature.AllowISO8601DateFormat, true);
        Object value = parser.parse();
        Assert.assertEquals(new Date(1294552193254L), value);
    }

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

        Assert.assertEquals(new Date(1294552193254L), value);
    }

    public void test_9() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("");
        parser.config(Feature.AllowISO8601DateFormat, true);
        Object value = parser.parse();
        Assert.assertEquals(null, value);
    }

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

    }

    public void test_15() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("[1,null]");
        ArrayList list = new ArrayList();
        parser.config(Feature.AllowISO8601DateFormat, false);
        parser.parseArray(String.class, list);
        Assert.assertEquals("1", list.get(0));
        Assert.assertEquals(null, list.get(1));
    }
View Full Code Here

        Assert.assertEquals(null, list.get(1));
    }

    public void test_16() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("[[1]]");
        parser.config(Feature.AllowISO8601DateFormat, false);
        Object[] array = parser.parseArray(new Type[] { new TypeReference<List<Integer>>() {
        }.getType() });
        Assert.assertEquals(new Integer(1), ((List<Integer>) (array[0])).get(0));
    }
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.