Java源码示例:com.alibaba.fastjson.parser.deserializer.ParseProcess

示例1
/**
 * wzy扩展
 *
 * @param input
 * @param value
 * @param config
 * @param processor
 * @param featureValues
 * @param features
 */
private static void reflectObject(String input, Object value, ParserConfig config, ParseProcess processor,
		int featureValues, Feature... features) {
	if (input == null) {
		return;
	}
	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);
	}
	parser.parseObject(value);
	parser.handleResovleTask(value);
	parser.close();
}
 
示例2
@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;
}
 
示例3
public static <T> T toObject(String json, Class<T> clazz, ParseProcess processor) {
    try {
        if (deserializerFeatures != null) {
            return JSON.parseObject(json, clazz, processor, deserializerFeatures);
        } else {
            return JSON.parseObject(json, clazz, processor);
        }
    } catch (JSONException e) {
        throw new JsonException("Could not cast \"" + json + "\" to " + clazz.getName(), e);
    }
}
 
示例4
public static <T> T toObject(String json, Class<T> clazz, ParseProcess processor, Feature... features) {
    try {
        return JSON.parseObject(json, clazz, processor, features);
    } catch (JSONException e) {
        throw new JsonException("Could not cast \"" + json + "\" to " + clazz.getName(), e);
    }
}
 
示例5
public static <T> T toObject(String json, Type type, ParseProcess processor) {
    try {
        if (deserializerFeatures != null) {
            return JSON.parseObject(json, type, processor, deserializerFeatures);
        } else {
            return JSON.parseObject(json, type, processor);
        }
    } catch (JSONException e) {
        throw new JsonException("Could not cast \"" + json + "\" to " + type.getClass().getName(), e);
    }
}
 
示例6
public static <T> T toObject(String json, Type type, ParseProcess processor, Feature... features) {
    try {
        return JSON.parseObject(json, type, processor, features);
    } catch (JSONException e) {
        throw new JsonException("Could not cast \"" + json + "\" to " + type.getClass().getName(), e);
    }
}
 
示例7
@SuppressWarnings("unchecked")
public static <T> T parseObject(String text, Class<T> clazz, ParseProcess processor, Feature... features) {
    return (T) parseObject(text, (Type) clazz, ParserConfig.global, processor, DEFAULT_PARSER_FEATURE,
                           features);
}
 
示例8
@SuppressWarnings("unchecked")
public static <T> T parseObject(String input, Type clazz, ParseProcess processor, Feature... features) {
    return (T) parseObject(input, clazz, ParserConfig.global, processor, DEFAULT_PARSER_FEATURE, features);
}