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, ParserConfig config, ParseProcess processor, int featureValues, Feature... features) {
if (input == null) {
return null;
}
if (features != null) {
for (Feature feature : features) {
featureValues |= feature.mask;
}
}
DefaultJSONParser parser = new DefaultJSONParser(input, config, featureValues);
if (processor != null) {
if (processor instanceof ExtraTypeProvider) {
parser.getExtraTypeProviders().add((ExtraTypeProvider) processor);
}
if (processor instanceof ExtraProcessor) {
parser.getExtraProcessors().add((ExtraProcessor) processor);
}
if (processor instanceof FieldTypeResolver) {
parser.setFieldTypeResolver((FieldTypeResolver) processor);
}
}
T value = (T) parser.parseObject(clazz, null);
parser.handleResovleTask(value);
parser.close();
return (T) value;
}
use of com.alibaba.fastjson.parser.Feature in project uavstack by uavorg.
the class JSON method parseObject.
@SuppressWarnings("unchecked")
public static final <T> T parseObject(String input, Type clazz, ParserConfig config, ParseProcess processor, int featureValues, Feature... features) {
if (input == null) {
return null;
}
for (Feature featrue : features) {
featureValues = Feature.config(featureValues, featrue, true);
}
DefaultJSONParser parser = new DefaultJSONParser(input, config, featureValues);
if (processor instanceof ExtraTypeProvider) {
parser.getExtraTypeProviders().add((ExtraTypeProvider) processor);
}
if (processor instanceof ExtraProcessor) {
parser.getExtraProcessors().add((ExtraProcessor) processor);
}
T value = (T) parser.parseObject(clazz);
parser.handleResovleTask(value);
parser.close();
return (T) value;
}
use of com.alibaba.fastjson.parser.Feature in project uavstack by uavorg.
the class JSON method parseObject.
@SuppressWarnings("unchecked")
public static final <T> T parseObject(char[] input, int length, Type clazz, Feature... features) {
if (input == null || input.length == 0) {
return null;
}
int featureValues = DEFAULT_PARSER_FEATURE;
for (Feature featrue : features) {
featureValues = Feature.config(featureValues, featrue, true);
}
DefaultJSONParser parser = new DefaultJSONParser(input, length, ParserConfig.getGlobalInstance(), featureValues);
T value = (T) parser.parseObject(clazz);
parser.handleResovleTask(value);
parser.close();
return (T) value;
}
use of com.alibaba.fastjson.parser.Feature in project fastjson by alibaba.
the class ArrayListStringDeserializerTest method parseObject.
public static final <T> T parseObject(String input, Type clazz, Feature... features) {
if (input == null) {
return null;
}
int featureValues = 0;
for (Feature feature : features) {
featureValues = Feature.config(featureValues, feature, true);
}
DefaultJSONParser parser = new DefaultJSONParser(input, ParserConfig.getGlobalInstance(), featureValues);
T value = (T) parser.parseObject(clazz);
if (clazz != JSONArray.class) {
parser.close();
}
return (T) value;
}
use of com.alibaba.fastjson.parser.Feature in project fastjson by alibaba.
the class BooleanFieldSerializerTest method parseObjectNoAsm.
@SuppressWarnings("unchecked")
public static final <T> T parseObjectNoAsm(String input, Type clazz, int featureValues, Feature... features) {
if (input == null) {
return null;
}
for (Feature feature : features) {
featureValues = Feature.config(featureValues, feature, true);
}
ParserConfig config = new ParserConfig();
config.setAsmEnable(false);
DefaultJSONParser parser = new DefaultJSONParser(input, config, featureValues);
T value = (T) parser.parseObject(clazz);
if (clazz != JSONArray.class) {
parser.close();
}
return (T) value;
}
Aggregations