Package com.alibaba.fastjson.parser

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


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

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


    public void test_not_match_error() throws Exception {
        Exception error = null;
        try {
            String text = "[{\"old\":false,\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123, \"kxxx\":33}]";
            DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
            parser.config(Feature.IgnoreNotMatch, false);
            Assert.assertEquals(true, (parser.parseArray(User.class).get(0) instanceof User));
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
View Full Code Here

public class DefaultExtJSONParserTest_5 extends TestCase {
   
    public void test_0() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("{,,,,\"value\":3,\"id\":1}");
        parser.config(Feature.AllowArbitraryCommas, true);
        Entity entity = new Entity();
        parser.parseObject(entity);
        Assert.assertEquals(3, entity.getValue());
    }
   
View Full Code Here

        Assert.assertEquals(3, entity.getValue());
    }
   
    public void test_1() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("{\"value\":3,\"id\":1}");
        parser.config(Feature.AllowArbitraryCommas, false);
        Entity entity = new Entity();
        parser.parseObject(entity);
        Assert.assertEquals(3, entity.getValue());
    }
View Full Code Here

        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

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.