Search in sources :

Example 6 with Feature

use of com.alibaba.fastjson.parser.Feature in project fastjson by alibaba.

the class JSON method parseObject.

@SuppressWarnings("unchecked")
public static <T> T parseObject(String input, Type clazz, int featureValues, Feature... features) {
    if (input == null) {
        return null;
    }
    for (Feature feature : features) {
        featureValues = Feature.config(featureValues, feature, true);
    }
    DefaultJSONParser parser = new DefaultJSONParser(input, ParserConfig.getGlobalInstance(), featureValues);
    T value = (T) parser.parseObject(clazz);
    parser.handleResovleTask(value);
    parser.close();
    return (T) value;
}
Also used : DefaultJSONParser(com.alibaba.fastjson.parser.DefaultJSONParser) SerializerFeature(com.alibaba.fastjson.serializer.SerializerFeature) Feature(com.alibaba.fastjson.parser.Feature)

Aggregations

DefaultJSONParser (com.alibaba.fastjson.parser.DefaultJSONParser)6 Feature (com.alibaba.fastjson.parser.Feature)6 SerializerFeature (com.alibaba.fastjson.serializer.SerializerFeature)5 ParserConfig (com.alibaba.fastjson.parser.ParserConfig)2 ExtraProcessor (com.alibaba.fastjson.parser.deserializer.ExtraProcessor)1 ExtraTypeProvider (com.alibaba.fastjson.parser.deserializer.ExtraTypeProvider)1 FieldTypeResolver (com.alibaba.fastjson.parser.deserializer.FieldTypeResolver)1