Package com.alibaba.fastjson.parser

Examples of com.alibaba.fastjson.parser.DefaultExtJSONParser


        }
        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


        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, {}]");
        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

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

        Object value = parser.parse();
        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);
    }
View Full Code Here

        Object value = parser.parse();
        Assert.assertEquals(null, value);
    }

    public void test_error_2() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("{}");
        Exception error = null;
        try {
            parser.accept(JSONToken.NULL);
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
View Full Code Here

        }
        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

        Assert.assertEquals(new Integer(2), values[1]);
        Assert.assertEquals(new Integer(3), values[2]);
    }

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

        Object[] array = parser.parseArray(new Type[] { String.class });
        Assert.assertEquals("1", array[0]);
    }

    public void test_12() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("['1']");
        Object[] array = parser.parseArray(new Type[] { int.class });
        Assert.assertEquals(new Integer(1), array[0]);
    }
View Full Code Here

        Object[] array = parser.parseArray(new Type[] { int.class });
        Assert.assertEquals(new Integer(1), array[0]);
    }

    public void test_13() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("['1']");
        Object[] array = parser.parseArray(new Type[] { Integer.class });
        Assert.assertEquals(new Integer(1), array[0]);
    }
View Full Code Here

        Object[] array = parser.parseArray(new Type[] { Integer.class });
        Assert.assertEquals(new Integer(1), array[0]);
    }

    public void test_14() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("[]");
        Object[] array = parser.parseArray(new Type[] {});
        Assert.assertEquals(0, array.length);
    }
View Full Code Here

TOP

Related Classes of com.alibaba.fastjson.parser.DefaultExtJSONParser

Copyright © 2018 www.massapicom. 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.