Package com.alibaba.fastjson.parser

Examples of com.alibaba.fastjson.parser.ParserConfig


        config.getDerializers();
        config.getDefaultSerializer();
    }

    public void test_error_0() throws Exception {
        ParserConfig config = new ParserConfig();
       
        Exception error = null;
        try {
            config.createJavaBeanDeserializer(int.class, int.class);
        } catch (JSONException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);
    }
View Full Code Here


    String text = JSON.toJSONString(v, mapping,
        SerializerFeature.WriteMapNullValue);
    Assert.assertEquals("{\"value\":123}", text);

    ParserConfig config = new ParserConfig();
    config.setAsmEnable(false);

    V0 v1 = JSON.parseObject(text, V0.class, config,
        JSON.DEFAULT_PARSER_FEATURE);

    Assert.assertEquals(v1.getValue(), v.getValue());
View Full Code Here

        mapping.setAsmEnable(false);

        String text = JSON.toJSONString(v, mapping, SerializerFeature.WriteMapNullValue);
        Assert.assertEquals("{\"value\":null}", text);

        ParserConfig config = new ParserConfig();
        config.setAsmEnable(false);
       
        V0 v1 = JSON.parseObject(text, V0.class, config, JSON.DEFAULT_PARSER_FEATURE);

        Assert.assertEquals(v1.getValue(), v.getValue());
    }
View Full Code Here

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

        ParserConfig config = new ParserConfig();
        config.setAsmEnable(false);

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

        if (clazz != JSONArray.class) {
View Full Code Here

   
    public void test_create_2() throws Exception {
        Entity entity = new Entity(123, "菜姐");
        String text = JSON.toJSONString(entity);
       
        ParserConfig config = new ParserConfig();
        config.setAsmEnable(false);
       
        Entity entity2 = JSON.parseObject(text, Entity.class, config, 0);
        Assert.assertEquals(entity.getId(), entity2.getId());
        Assert.assertEquals(entity.getName(), entity2.getName());
    }
View Full Code Here

        entity.getChild().setParent(entity);

        String text = JSON.toJSONString(entity);
        System.out.println(text);

        ParserConfig config = new ParserConfig();
        config.setAsmEnable(false);
        Entity entity2 = JSON.parseObject(text, Entity.class, config, 0);

        Assert.assertEquals(entity2, entity2.getChild().getParent());

        System.out.println(JSON.toJSONString(entity2));
View Full Code Here

    public void test_bug() throws Exception {
        TestBean testProcessInfo = new TestBean();
        com.alibaba.fastjson.JSONObject jo = new com.alibaba.fastjson.JSONObject();
        jo.put("id", 121);
        ParserConfig config = new ParserConfig();
        testProcessInfo = TypeUtils.cast(jo, TestBean.class, config);
    }
View Full Code Here

        entity.getChild().setParent(entity);

        String text = JSON.toJSONString(entity);
        System.out.println(text);

        ParserConfig config = new ParserConfig();
        config.setAsmEnable(false);
        Entity entity2 = JSON.parseObject(text, Entity.class, config, 0);

        Assert.assertEquals(entity2, entity2.getChild().getParent());

        System.out.println(JSON.toJSONString(entity2));
View Full Code Here

import com.alibaba.fastjson.parser.ParserConfig;

public class TestNonASM extends TestCase {

    public void test_no_asm() throws Exception {
        ParserConfig mapping = new ParserConfig();
       
        mapping.setAsmEnable(false);
        Assert.assertEquals(false, mapping.isAsmEnable());
       
        mapping.setAsmEnable(true);
        Assert.assertEquals(true, mapping.isAsmEnable());
    }
View Full Code Here

    public void xx_testCast() {
        Page<Sub> page = new Page<Sub>(new Sub(1));
        Type type = new TypeReference<Page<Sub>>() {
        }.getType();
        ParserConfig parserconfig = ParserConfig.getGlobalInstance();
        // !!!! this will fail:
        // !!!! com.alibaba.fastjson.JSONException: can not cast to : Page<Sub> TypeUtils.java:719
        Page<Sub> page1 = TypeUtils.cast(page, type, parserconfig);
        System.out.println(page1.sub.getClass());
    }
View Full Code Here

TOP

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

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.