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 . 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 check out the related API usage on the sidebar.
Example 1
Source File: FastJsonKvCodecTest.java    From actframework with Apache License 2.0 5 votes vote down vote up
@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
Source File: TSDBClientTest.java    From aliyun-tsdb-java-sdk with Apache License 2.0 4 votes vote down vote up
@Before
public void setup() {
    JSON.DEFAULT_PARSER_FEATURE &= ~Feature.UseBigDecimal.getMask();
}
 
Example 3
Source File: JSONReaderScanner.java    From uavstack with Apache License 2.0 4 votes vote down vote up
public JSONReaderScanner(String input){
    this(input, JSON.DEFAULT_PARSER_FEATURE);
}
 
Example 4
Source File: JSONReaderScanner.java    From uavstack with 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 File: JSONReaderScanner.java    From uavstack with Apache License 2.0 4 votes vote down vote up
public JSONReaderScanner(Reader reader){
    this(reader, JSON.DEFAULT_PARSER_FEATURE);
}
 
Example 6
Source File: JSONScanner.java    From uavstack with Apache License 2.0 4 votes vote down vote up
public JSONScanner(String input){
    this(input, JSON.DEFAULT_PARSER_FEATURE);
}
 
Example 7
Source File: JSONScanner.java    From uavstack with 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
Source File: HswebAutoConfiguration.java    From hsweb-framework with Apache License 2.0 4 votes vote down vote up
@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;
}