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

    return parse(text, featureValues);
  }
Esempio n. 3
0
  public static final 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 featrue : features) {
      featureValues = Feature.config(featureValues, featrue, true);
    }

    return parse(input, off, len, charsetDecoder, featureValues);
  }
Esempio n. 4
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;
  }
Esempio n. 5
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;
  }