Esempio n. 1
0
  @SuppressWarnings("unchecked")
  public static <T> T parseObject(
      String input,
      Type clazz,
      ParserConfig config,
      ParseProcess processor,
      int featureValues,
      Feature... features) {
    if (input == null) {
      return null;
    }

    for (Feature feature : features) {
      featureValues = Feature.config(featureValues, feature, 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;
  }
Esempio n. 2
0
  public static Object parse(String text, Feature... features) {
    int featureValues = DEFAULT_PARSER_FEATURE;
    for (Feature feature : features) {
      featureValues = Feature.config(featureValues, feature, true);
    }

    return parse(text, featureValues);
  }
Esempio n. 3
0
  public static Object parse(
      byte[] input, int off, int len, CharsetDecoder charsetDecoder, Feature... features) {
    if (input == null || input.length == 0) {
      return null;
    }

    int featureValues = DEFAULT_PARSER_FEATURE;
    for (Feature feature : features) {
      featureValues = Feature.config(featureValues, feature, true);
    }

    return parse(input, off, len, charsetDecoder, featureValues);
  }
Esempio n. 4
0
  @SuppressWarnings("unchecked")
  public static <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 feature : features) {
      featureValues = Feature.config(featureValues, feature, true);
    }

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

    parser.handleResovleTask(value);

    parser.close();

    return (T) value;
  }
Esempio n. 5
0
  @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;
  }