Examples of parseArrayWithType()


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

    }

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

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

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

public class DefaultExtJSONParser_parseArray_2 extends TestCase {

    public void test_0() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("[['1']]");
        parser.config(Feature.AllowISO8601DateFormat, false);
        List<List<Integer>> list = (List<List<Integer>>) parser.parseArrayWithType(new TypeReference<List<List<Integer>>>() {
        }.getType());
        Assert.assertEquals(new Integer(1), list.get(0).get(0));
    }

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

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

        DefaultExtJSONParser parser = new DefaultExtJSONParser("[['1']]");
        parser.config(Feature.AllowISO8601DateFormat, false);

        Exception error = null;
        try {
            parser.parseArrayWithType(new TypeReference<Map<?, ?>>() {
            }.getType());
        } catch (Exception ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
View Full Code Here

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

                                                                 Collection.class, Collection.class);
        Type[] types = method.getGenericParameterTypes();
        {
            String text = "[{\"old\":false,\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123}]";
            DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
            Assert.assertEquals(true, ((List) parser.parseArrayWithType(types[0])).get(0) instanceof Map);
        }
        {
            String text = "[{\"old\":false,\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123}]";
            DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
            Assert.assertEquals(true, ((List) parser.parseArrayWithType(types[1])).get(0) instanceof User);
View Full Code Here

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

            Assert.assertEquals(true, ((List) parser.parseArrayWithType(types[0])).get(0) instanceof Map);
        }
        {
            String text = "[{\"old\":false,\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123}]";
            DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
            Assert.assertEquals(true, ((List) parser.parseArrayWithType(types[1])).get(0) instanceof User);
        }
        {
            Exception error = null;
            try {
                String text = "[{\"old\":false,\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123}]";
View Full Code Here

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

        {
            Exception error = null;
            try {
                String text = "[{\"old\":false,\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123}]";
                DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
                parser.parseArrayWithType(types[2]);
                ;
            } catch (Exception ex) {
                error = ex;
            }
            Assert.assertNotNull(error);
View Full Code Here

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

            Assert.assertNotNull(error);
        }
        {
            String text = "[{\"old\":false,\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123}]";
            DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
            Assert.assertEquals(true, ((List) parser.parseArrayWithType(types[3])).get(0) instanceof User);
        }
        {
            Exception error = null;
            try {
                String text = "[{\"old\":false,\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123}]";
View Full Code Here

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

        {
            Exception error = null;
            try {
                String text = "[{\"old\":false,\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123}]";
                DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
                parser.parseArrayWithType(types[4]);
                ;
            } catch (Exception ex) {
                error = ex;
            }
            Assert.assertNotNull(error);
View Full Code Here

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

            Assert.assertNotNull(error);
        }
        {
            String text = "[{\"old\":false,\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123}]";
            DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
            Assert.assertEquals(true, ((List) parser.parseArrayWithType(types[5])).get(0) instanceof User);
        }

        {
            Exception error = null;
            try {
View Full Code Here

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

        {
            Exception error = null;
            try {
                String text = "[{\"old\":false,\"name\":\"校长\",\"age\":3,\"salary\":123456789.0123}]";
                DefaultExtJSONParser parser = new DefaultExtJSONParser(text);
                parser.parseArrayWithType(types[6]);
                ;
            } catch (Exception ex) {
                error = ex;
            }
            Assert.assertNotNull(error);
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.