Package com.alibaba.fastjson.parser

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


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

    public static class Entity {
View Full Code Here


            int featureValues = 0;
            DefaultExtJSONParser parser = new DefaultExtJSONParser(input, ParserConfig.getGlobalInstance(),
                                                                   featureValues);

            Entity object = new Entity();
            parser.parseObject(object);
        } catch (JSONException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
View Full Code Here

            int featureValues = 0;
            DefaultExtJSONParser parser = new DefaultExtJSONParser(input, ParserConfig.getGlobalInstance(),
                                                                   featureValues);

            Entity object = new Entity();
            parser.parseObject(object);
        } catch (JSONException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
View Full Code Here

    public void test_0() throws Exception {
        DefaultExtJSONParser parser = new DefaultExtJSONParser("{\"id\":3, \"name\":\"xx\"}", ParserConfig.getGlobalInstance());

        Entity entity = new Entity();
        parser.parseObject(entity);
    }

    public void test_1() throws Exception {
        JSON.parseObject("{\"id\":3, \"name\":\"xx\"}", Entity.class, 0, Feature.IgnoreNotMatch);
    }
View Full Code Here

        for (Feature featrue : features) {
            featureValues = Feature.config(featureValues, featrue, true);
        }

        DefaultExtJSONParser parser = new DefaultExtJSONParser(input, ParserConfig.getGlobalInstance(), featureValues);
        T value = (T) parser.parseObject(clazz);

        if (clazz != JSONArray.class) {
            parser.close();
        }
View Full Code Here

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

    public void test_1() throws Exception {
        String text = "0";
View Full Code Here

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

    public void test_error() throws Exception {
        Exception error = null;
View Full Code Here

        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

        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

        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

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.