当前位置: 首页>>代码示例>>Java>>正文


Java JsonTokenId.ID_STRING属性代码示例

本文整理汇总了Java中com.fasterxml.jackson.core.JsonTokenId.ID_STRING属性的典型用法代码示例。如果您正苦于以下问题:Java JsonTokenId.ID_STRING属性的具体用法?Java JsonTokenId.ID_STRING怎么用?Java JsonTokenId.ID_STRING使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.fasterxml.jackson.core.JsonTokenId的用法示例。


在下文中一共展示了JsonTokenId.ID_STRING属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: writeValue

private void writeValue(JsonRecord value) throws IOException {
    switch (value.getKind()) {
        case JsonTokenId.ID_STRING:
            jg.writeString(value.getValue());
            break;
        case JsonTokenId.ID_NULL:
            jg.writeNull();
            break;
        case JsonTokenId.ID_NUMBER_FLOAT:
        case JsonTokenId.ID_NUMBER_INT:
            jg.writeNumber(value.getValue());
            break;
        case JsonTokenId.ID_TRUE:
            jg.writeBoolean(true);
            break;
        case JsonTokenId.ID_FALSE:
            jg.writeBoolean(false);
            break;
        default:
    }
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:21,代码来源:JsonRecordConsumer.java

示例2: deserialize

@Override
public Duration deserialize(JsonParser parser, DeserializationContext context) throws IOException {
    switch (parser.getCurrentTokenId()) {
        case JsonTokenId.ID_NUMBER_FLOAT:
            BigDecimal value = parser.getDecimalValue();
            long seconds = value.longValue();
            int nanoseconds = DecimalUtils.extractNanosecondDecimal(value, seconds);
            return Duration.ofSeconds(seconds, nanoseconds);

        case JsonTokenId.ID_NUMBER_INT:
            return Duration.ofSeconds(parser.getLongValue());

        case JsonTokenId.ID_STRING:
            String string = parser.getText().trim();
            if (string.length() == 0) {
                return null;
            }
            return Duration.parse(string);
    }
    throw context.mappingException("Expected type float, integer, or string.");
}
 
开发者ID:bootique,项目名称:bootique,代码行数:21,代码来源:DurationDeserializer.java

示例3: deserializeObject

private Cookies deserializeObject(JsonParser p, DeserializationContext ctxt, JsonNodeFactory nodeFactory) throws IOException {
    Cookies cookies = new Cookies();
    NottableString key = string("");
    while (true) {
        JsonToken t = p.nextToken();
        switch (t.id()) {
            case JsonTokenId.ID_FIELD_NAME:
                key = string(ctxt.readValue(p, String.class));
                break;
            case JsonTokenId.ID_STRING:
                cookies.withEntry(key, string(ctxt.readValue(p, String.class)));
                break;
            case JsonTokenId.ID_END_OBJECT:
                return cookies;
            default:
                throw new RuntimeException("Unexpected token: \"" + t + "\" id: \"" + t.id() + "\" text: \"" + p.getText());
        }
    }
}
 
开发者ID:jamesdbloom,项目名称:mockserver,代码行数:19,代码来源:CookiesDeserializer.java

示例4: processValue

/**
 * Uses a JsonToken + JsonParser to determine how to write a value to the JsonGenerator.
 *
 * <p>This separation exists so we can separate the iteration logic from the parsing logic.
 *
 * @param valueToken current token we are interested in from the parser
 * @param parser current parser
 * @param jgen JsonGenerator that is used for writing json onto an underlying stream
 * @throws JsonGenerationException if access to the JsonParser throws a JsonGenerationException
 * @throws IOException if the Jackson utilties (JsonParser or JsonGenerator) throw an IOException
 */
private void processValue(JsonToken valueToken, JsonParser parser, JsonGenerator jgen)
    throws IOException {
  if (valueToken.isBoolean()) {
    jgen.writeBoolean(parser.getBooleanValue());
  } else if (valueToken.isNumeric()) {
    if (parser.getNumberType() == JsonParser.NumberType.INT) {
      jgen.writeNumber(parser.getIntValue());
    } else if (parser.getNumberType() == JsonParser.NumberType.DOUBLE) {
      jgen.writeNumber(parser.getDoubleValue());
    } else if (parser.getNumberType() == JsonParser.NumberType.FLOAT) {
      jgen.writeNumber(parser.getFloatValue());
    } else if (parser.getNumberType() == JsonParser.NumberType.LONG) {
      jgen.writeNumber(parser.getLongValue());
    } else if (parser.getNumberType() == JsonParser.NumberType.BIG_DECIMAL) {
      jgen.writeNumber(parser.getDecimalValue());
    } else if (parser.getNumberType() == JsonParser.NumberType.BIG_INTEGER) {
      jgen.writeNumber(parser.getBigIntegerValue());
    } else {
      LOGGER.error("Found unsupported numeric value with name {}.", parser.getCurrentName());
      throw new RuntimeException(
          "Found unsupported numeric value with name " + parser.getCurrentName());
    }
  } else if (valueToken.id() == JsonTokenId.ID_STRING) {
    jgen.writeString(parser.getText());
  } else {
    // Something bad just happened. Probably an unsupported type.
    LOGGER.error(
        "Found unsupported value type {} for name {}.", valueToken.id(), parser.getCurrentName());
    throw new RuntimeException(
        "Found unsupported value type " + valueToken.id() + " for name " + parser
            .getCurrentName());
  }
}
 
开发者ID:cerner,项目名称:beadledom,代码行数:44,代码来源:FieldFilter.java

示例5: deserialize

@Override
public Duration deserialize(JsonParser parser, DeserializationContext context) throws IOException
{
    switch (parser.currentTokenId())
    {
        case JsonTokenId.ID_NUMBER_FLOAT:
            BigDecimal value = parser.getDecimalValue();
            long seconds = value.longValue();
            int nanoseconds = DecimalUtils.extractNanosecondDecimal(value, seconds);
            return Duration.ofSeconds(seconds, nanoseconds);

        case JsonTokenId.ID_NUMBER_INT:
            if(context.isEnabled(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)) {
                return Duration.ofSeconds(parser.getLongValue());
            }
            return Duration.ofMillis(parser.getLongValue());

        case JsonTokenId.ID_STRING:
            String string = parser.getText().trim();
            if (string.length() == 0) {
                return null;
            }
            try {
                return Duration.parse(string);
            } catch (DateTimeException e) {
                return _rethrowDateTimeException(parser, context, e, string);
            }
        case JsonTokenId.ID_EMBEDDED_OBJECT:
            // 20-Apr-2016, tatu: Related to [databind#1208], can try supporting embedded
            //    values quite easily
            return (Duration) parser.getEmbeddedObject();
            
        case JsonTokenId.ID_START_ARRAY:
        	return _deserializeFromArray(parser, context);
    }
    return _reportWrongToken(parser, context, JsonToken.VALUE_STRING,
            JsonToken.VALUE_NUMBER_INT, JsonToken.VALUE_NUMBER_FLOAT);
}
 
开发者ID:FasterXML,项目名称:jackson-modules-java8,代码行数:38,代码来源:DurationDeserializer.java

示例6: deserializeArray

private Cookies deserializeArray(JsonParser p, DeserializationContext ctxt, JsonNodeFactory nodeFactory) throws IOException {
    Cookies headers = new Cookies();
    NottableString key = null;
    NottableString value = null;
    String fieldName = null;
    while (true) {
        JsonToken t = p.nextToken();
        switch (t.id()) {
            case JsonTokenId.ID_END_ARRAY:
                return headers;
            case JsonTokenId.ID_START_OBJECT:
                key = null;
                value = null;
                break;
            case JsonTokenId.ID_FIELD_NAME:
                fieldName = ctxt.readValue(p, String.class);
                break;
            case JsonTokenId.ID_STRING:
                if ("name".equals(fieldName)) {
                    key = string(ctxt.readValue(p, String.class));
                } else if ("value".equals(fieldName)) {
                    value = string(ctxt.readValue(p, String.class));
                }
                break;
            case JsonTokenId.ID_END_OBJECT:
                headers.withEntry(key, value);
                break;
            default:
                throw new RuntimeException("Unexpected token: \"" + t + "\" id: \"" + t.id() + "\" text: \"" + p.getText());
        }
    }
}
 
开发者ID:jamesdbloom,项目名称:mockserver,代码行数:32,代码来源:CookiesDeserializer.java

示例7: parseDocument

public void parseDocument(ElementHandler docHandler)
    throws IOException {

  push(docHandler);
  JsonToken tkn = parser.nextToken();
  while (null != tkn) {
    switch(tkn.id()) {
    case JsonTokenId.ID_START_OBJECT:
      ElementHandler newHandler = top().newObject();
      push(newHandler);
      break;
    case JsonTokenId.ID_END_OBJECT:
      ElementHandler endHandler = top();
      endHandler.endObject();
      pop();
      break;
    case JsonTokenId.ID_FIELD_NAME:
      ElementHandler fieldHandler = top();
      fieldHandler.fieldName(parser.getText());
      break;
    case JsonTokenId.ID_START_ARRAY:
      top().newArray();
      break;
    case JsonTokenId.ID_END_ARRAY:
      top().endArray();
      break;
    case JsonTokenId.ID_STRING:
      top().withString(parser.getText());
      break;
    case JsonTokenId.ID_NUMBER_INT:
      top().withBigInteger(parser.getBigIntegerValue());
      break;
    case JsonTokenId.ID_NUMBER_FLOAT:
      top().withBigDecimal(parser.getDecimalValue());
      break;
    case JsonTokenId.ID_TRUE:
      top().withBoolean(true);
      break;
    case JsonTokenId.ID_FALSE:
      top().withBoolean(false);
      break;
    case JsonTokenId.ID_NULL:
      top().withNull();
      break;
    default:
      PushJsonLogger.LOG.warn(fmtToken(tkn, parser.getText()));
      break;
    }

    // Keep going
    tkn = parser.nextToken();
  }
}
 
开发者ID:google,项目名称:depan,代码行数:53,代码来源:PushDownJsonHandler.java


注:本文中的com.fasterxml.jackson.core.JsonTokenId.ID_STRING属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。