Package com.alibaba.fastjson.parser

Examples of com.alibaba.fastjson.parser.DefaultExtJSONParser


        }
        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) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
View Full Code Here


public class EnumParserTest extends TestCase {

    public void test_0() throws Exception {
        String text = "\"A\"";
        DefaultExtJSONParser parser = new DefaultExtJSONParser(text);

        Type type = parser.parseObject(Type.class);
        Assert.assertEquals(Type.A, type);
    }
View Full Code Here

        Assert.assertEquals(Type.A, type);
    }

    public void test_1() throws Exception {
        String text = "0";
        DefaultExtJSONParser parser = new DefaultExtJSONParser(text);

        Type type = parser.parseObject(Type.class);
        Assert.assertEquals(Type.A, type);
    }
View Full Code Here

    public void test_error() throws Exception {
        Exception error = null;
        try {
            String text = "\"C\"";
            DefaultExtJSONParser parser = new DefaultExtJSONParser(text);

            parser.parseObject(Type.class);
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
View Full Code Here

    public void test_error_1() throws Exception {
        Exception error = null;
        try {
            String text = "4";
            DefaultExtJSONParser parser = new DefaultExtJSONParser(text);

            parser.parseObject(Type.class);
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
View Full Code Here

    public void test_error_2() throws Exception {
        Exception error = null;
        try {
            String text = "4";
            DefaultExtJSONParser parser = new DefaultExtJSONParser(text);

            parser.parseObject(TypeA.class);
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
View Full Code Here

    public void test_error_3() throws Exception {
        Exception error = null;
        try {
            String text = "4";
            DefaultExtJSONParser parser = new DefaultExtJSONParser(text);

            new EnumDeserializer(Object.class).deserialze(parser, Object.class, null);
        } catch (Exception ex) {
            error = ex;
        }
View Full Code Here

    public void test_error_4() throws Exception {
        Exception error = null;
        try {
            String text = "true";
            DefaultExtJSONParser parser = new DefaultExtJSONParser(text);

            new EnumDeserializer(Object.class).deserialze(parser, Object.class, null);
        } catch (Exception ex) {
            error = ex;
        }
View Full Code Here

    public void test_0() throws Exception {
        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);
            List<Object> basicRes = new ArrayList<Object>();
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);
            basic.config(Feature.AllowArbitraryCommas, true);
            JSONObject basicRes = basic.parseObject();
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.