Examples of parseArray()


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

public class DefaultExtJSONParser_parseArray extends TestCase {

    public void test_0() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("[1,2,,,3]");
        List list = new ArrayList();
        parser.parseArray(int.class, list);
        Assert.assertEquals("[1, 2, 3]", list.toString());
    }

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

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

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

    public void test_2() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("['1','2','3']");
View Full Code Here

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

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

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

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

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

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

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

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

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

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

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

    public void test_5() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("[1,2,3,null]");
        Object[] array = parser.parseArray(new Type[] { Integer.class, BigDecimal.class, Long.class, String.class });
        Assert.assertEquals(new Integer(1), array[0]);
        Assert.assertEquals(new BigDecimal("2"), array[1]);
        Assert.assertEquals(new Long(3), array[2]);
        Assert.assertEquals(null, array[3]);
    }
View Full Code Here

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

    public void test_error() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("{}");
        Exception error = null;
        try {
            parser.parseArray(new ArrayList());
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
View Full Code Here

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

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

    public void test_7() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("[\"2011-01-09T13:49:53.254\", \"xxx\", true, false, null, {}]");
View Full Code Here

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

    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));
        Assert.assertEquals(Boolean.FALSE, list.get(3));
        Assert.assertEquals(null, list.get(4));
View Full Code Here

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

        Assert.assertNotNull(error);
    }

    public void test_10() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("[1,2,3]");
        Object[] array = parser.parseArray(new Type[] { Integer[].class });
        Integer[] values = (Integer[]) array[0];
        Assert.assertEquals(new Integer(1), values[0]);
        Assert.assertEquals(new Integer(2), values[1]);
        Assert.assertEquals(new Integer(3), values[2]);
    }
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.