Ejemplo n.º 1
0
  @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;
  }
Ejemplo n.º 2
0
  @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;
  }
Ejemplo n.º 3
0
  @SuppressWarnings("unchecked")
  public static final <T> T parseObject(
      String input, Type clazz, int featureValues, Feature... features) {
    if (input == null) {
      return null;
    }

    for (Feature featrue : features) {
      featureValues = Feature.config(featureValues, featrue, true);
    }

    DefaultJSONParser parser =
        new DefaultJSONParser(input, ParserConfig.getGlobalInstance(), featureValues);
    T value = (T) parser.parseObject(clazz);

    parser.handleResovleTask(value);

    parser.close();

    return (T) value;
  }