Java Code Examples for com.alibaba.fastjson.JSON#DEFAULT_PARSER_FEATURE

The following examples show how to use com.alibaba.fastjson.JSON#DEFAULT_PARSER_FEATURE . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
@BeforeClass
public static void prepare() {
    SerializeConfig config = SerializeConfig.getGlobalInstance();
    config.put(KV.class, FastJsonKvCodec.INSTANCE);
    config.put(KVStore.class, FastJsonKvCodec.INSTANCE);

    ParserConfig parserConfig = ParserConfig.getGlobalInstance();
    parserConfig.putDeserializer(KV.class, FastJsonKvCodec.INSTANCE);
    parserConfig.putDeserializer(KVStore.class, FastJsonKvCodec.INSTANCE);

    JSON.DEFAULT_PARSER_FEATURE = Feature.config(JSON.DEFAULT_PARSER_FEATURE, Feature.UseBigDecimal, false);
}
 
Example 2
@Before
public void setup() {
    JSON.DEFAULT_PARSER_FEATURE &= ~Feature.UseBigDecimal.getMask();
}
 
Example 3
Source Project: uavstack   File: JSONReaderScanner.java    License: Apache License 2.0 4 votes vote down vote up
public JSONReaderScanner(String input){
    this(input, JSON.DEFAULT_PARSER_FEATURE);
}
 
Example 4
Source Project: uavstack   File: JSONReaderScanner.java    License: Apache License 2.0 4 votes vote down vote up
public JSONReaderScanner(char[] input, int inputLength){
    this(input, inputLength, JSON.DEFAULT_PARSER_FEATURE);
}
 
Example 5
Source Project: uavstack   File: JSONReaderScanner.java    License: Apache License 2.0 4 votes vote down vote up
public JSONReaderScanner(Reader reader){
    this(reader, JSON.DEFAULT_PARSER_FEATURE);
}
 
Example 6
Source Project: uavstack   File: JSONScanner.java    License: Apache License 2.0 4 votes vote down vote up
public JSONScanner(String input){
    this(input, JSON.DEFAULT_PARSER_FEATURE);
}
 
Example 7
Source Project: uavstack   File: JSONScanner.java    License: Apache License 2.0 4 votes vote down vote up
public JSONScanner(char[] input, int inputLength){
    this(input, inputLength, JSON.DEFAULT_PARSER_FEATURE);
}
 
Example 8
@Bean
@Primary
@ConfigurationProperties(prefix = "fastjson")
public FastJsonGenericHttpMessageConverter fastJsonGenericHttpMessageConverter(EntityFactory entityFactory) {
    JSON.DEFAULT_PARSER_FEATURE |= Feature.DisableFieldSmartMatch.getMask();
    FastJsonGenericHttpMessageConverter converter = new FastJsonGenericHttpMessageConverter();
    converter.setFeatures(
            SerializerFeature.WriteNullListAsEmpty,
            SerializerFeature.WriteNullNumberAsZero,
            SerializerFeature.WriteNullBooleanAsFalse
    );
    converter.setConverters(converters);
    ParserConfig.global = new ParserConfig() {
        @Override
        public ObjectDeserializer getDeserializer(Type type) {
            ObjectDeserializer derializer = getDeserializers().get(type);
            if (derializer != null) {
                return derializer;
            }
            if (type instanceof Class) {
                Class classType = ((Class) type);
                if (classType.isEnum()) {
                    return super.getDeserializer(type);
                }
                checkAutoType(type.getTypeName(), ((Class) type));
                if (Modifier.isAbstract(classType.getModifiers()) || Modifier.isInterface(classType.getModifiers())) {
                    Class realType;
                    if (entityFactory != null && (realType = entityFactory.getInstanceType(classType)) != null) {
                        return new JavaBeanDeserializer(this, realType, type);
                    }
                } else {
                    return new JavaBeanDeserializer(this, classType);
                }
            }

            return super.getDeserializer(type);
        }
    };

    //fastjson.parser.autoTypeAccept
    ParserConfig.global.addAccept("org.hswebframework.web.entity.");
    ParserConfig.global.addDeny("org.hswebframework.ezorm.core.param.SqlTerm");
    return converter;
}