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


Java JsonParser.getValueAsString方法代码示例

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


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

示例1: deserialize

import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
@Override public AnInterface deserialize(JsonParser jp, DeserializationContext ctxt)
    throws IOException {
  if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
    throw new AssertionError("Expected start object.");
  }

  String name = null;

  while (jp.nextToken() != JsonToken.END_OBJECT) {
    switch (jp.getCurrentName()) {
      case "name":
        name = jp.getValueAsString();
        break;
    }
  }

  return new AnImplementation(name);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:JacksonConverterFactoryTest.java

示例2: readRecord

import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
Map<String, Object> readRecord(JsonParser jp) throws IOException {

        Map<String, Object> record = new HashMap<>();
        String fielName =  "";
        Object value;
        JsonToken token;

        while((token = jp.nextToken()) != JsonToken.END_OBJECT) {
            if (token == JsonToken.FIELD_NAME) {
                fielName = jp.getCurrentName();
            } else if (token == JsonToken.VALUE_STRING) {
                value = jp.getValueAsString();
                record.put(fielName, value);
            } else if (token == JsonToken.VALUE_NUMBER_INT) {
                value = jp.getValueAsLong();
                record.put(fielName, value);
            }
        }

        //System.out.println(record.toString());
        return record;
    }
 
开发者ID:claudiodegio,项目名称:dbsync,代码行数:23,代码来源:JsonDatabaseReader.java

示例3: getValueFromFieldType

import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
public static Object getValueFromFieldType(JsonParser parser, MinorType fieldType) throws IOException {
  switch (fieldType) {
    case BIGINT:
      return parser.getLongValue();
    case VARCHAR:
      return parser.getValueAsString();
    case FLOAT4:
      return parser.getFloatValue();
    case BIT:
      return parser.getBooleanValue();
    case LATE:
    case NULL:
      return null;
    default:
      throw new RuntimeException("Unexpected Field type to return value: " + fieldType.toString());
  }
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:18,代码来源:JacksonHelper.java

示例4: deserializeWithRetry

import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
private Collection<Object> deserializeWithRetry(JsonParser p, DeserializationContext ctxt, JavaType contentType) throws IOException {
    final CollectionType collectionType = ctxt.getTypeFactory().constructCollectionType(Collection.class, contentType);

    try {
        return p.getCodec().readValue(p, collectionType);

    } catch (JsonMappingException e) {
        // attempt to read the value as string
        final String escapedString = p.getValueAsString();

        // stop here if value could not be read
        if (isNull(escapedString)) {
            throw ctxt.instantiationException(Collection.class, "Read null value when attempting to deserialize " + collectionType.toString());
        }

        // un-escape double quotes
        String unescapedString = escapedString.replaceAll("\"", "\"");

        // and attempt to parse again
        return new ObjectMapper().readValue(unescapedString, collectionType);
    }
}
 
开发者ID:salesforce,项目名称:pyplyn,代码行数:23,代码来源:RawJsonCollectionDeserializer.java

示例5: parseField

import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
@Override
protected void parseField(String fieldName, JsonParser parser) throws IOException {
    switch (fieldName) {
        case "order_id":
            parser.nextToken();
            orderId = parser.getValueAsString();
            break;
        case "reason":
            parser.nextToken();
            reason = parser.getValueAsString();
            break;
        case "remaining_size":
            parser.nextToken();
            remainingSize = new BigDecimal(parser.getValueAsString());
            break;
        default:
            break;
    }
}
 
开发者ID:cloudwall,项目名称:libcwfincore,代码行数:20,代码来源:MutableOrderDoneEvent.java

示例6: deserialize

import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
public static SubscribeMessage deserialize(JsonParser jp) throws IOException {
	jp.nextToken();
	long request = jp.getLongValue();

	MatchPolicy match = MatchPolicy.EXACT;

	jp.nextToken();
	boolean getRetained = false;
	Map<String, Object> options = ParserUtil.readObject(jp);
	if (options != null) {
		String extValue = (String) options.get("match");
		if (extValue != null) {
			match = MatchPolicy.fromExtValue(extValue);
			if (match == null) {
				match = MatchPolicy.EXACT;
			}
		}
		getRetained = (boolean) options.getOrDefault("get_retained", false);
	}

	jp.nextToken();
	String topic = jp.getValueAsString();

	return new SubscribeMessage(request, topic, match, getRetained);
}
 
开发者ID:ralscha,项目名称:wamp2spring,代码行数:26,代码来源:SubscribeMessage.java

示例7: deserialize

import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
public static ErrorMessage deserialize(JsonParser jp) throws IOException {
	jp.nextToken();
	int type = jp.getIntValue();

	jp.nextToken();
	long request = jp.getLongValue();

	jp.nextToken();
	ParserUtil.readObject(jp);

	jp.nextToken();
	String error = jp.getValueAsString();

	List<Object> arguments = null;
	JsonToken token = jp.nextToken();
	if (token == JsonToken.START_ARRAY) {
		arguments = ParserUtil.readArray(jp);
	}

	Map<String, Object> argumentsKw = null;
	token = jp.nextToken();
	if (token == JsonToken.START_OBJECT) {
		argumentsKw = ParserUtil.readObject(jp);
	}

	return new ErrorMessage(type, request, error, arguments, argumentsKw);
}
 
开发者ID:ralscha,项目名称:wamp2spring,代码行数:28,代码来源:ErrorMessage.java

示例8: deserialize

import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
@Override
public BigDecimal deserialize(final JsonParser parser, final DeserializationContext ctx) throws IOException {
    final String val = parser.getValueAsString();

    if ("N/A".equalsIgnoreCase(val)) {
        return null;
    }

    return parser.getDecimalValue();
}
 
开发者ID:WojciechZankowski,项目名称:iextrading4j,代码行数:11,代码来源:EmptyStringDeserializer.java

示例9: parseField

import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
@Override
public void parseField(MultipleFieldNamesModel instance, String fieldName, JsonParser jsonParser) throws IOException {
    if ("possible_double_name_1".equals(fieldName) || "possible_double_name_2".equals(fieldName)) {
        instance.testDouble = jsonParser.getValueAsDouble();
    } else if ("possible_float_name_1".equals(fieldName) || "possible_float_name_2".equals(fieldName)){
        instance.testFloat = (float)jsonParser.getValueAsDouble();
    } else if ("possible_int_name_1".equals(fieldName) || "possible_int_name_2".equals(fieldName)){
        instance.testInt = jsonParser.getValueAsInt();
    } else if ("possible_long_name_1".equals(fieldName) || "possible_long_name_2".equals(fieldName)){
        instance.testLong = jsonParser.getValueAsLong();
    } else if ("possible_string_name_1".equals(fieldName) || "possible_string_name_2".equals(fieldName)){
        instance.testString = jsonParser.getValueAsString(null);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:15,代码来源:MultipleFieldNamesModel$$JsonObjectMapper.java

示例10: parseField

import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
@Override
public void parseField(SimpleGenericModelWithExtends<T> instance, String fieldName, JsonParser jsonParser) throws IOException {
  if ("date".equals(fieldName)) {
    instance.date = getjava_util_Date_type_converter().parse(jsonParser);
  } else if ("string".equals(fieldName)) {
    instance.string = jsonParser.getValueAsString(null);
  } else if ("test_double".equals(fieldName)) {
    instance.testDouble = jsonParser.getValueAsDouble();
  } else if ("test_double_obj".equals(fieldName)) {
    instance.testDoubleObj = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : Double.valueOf(jsonParser.getValueAsDouble());
  } else if ("test_float".equals(fieldName)) {
    instance.testFloat = (float)jsonParser.getValueAsDouble();
  } else if ("test_float_obj".equals(fieldName)) {
    instance.testFloatObj = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : new Float(jsonParser.getValueAsDouble());
  } else if ("test_int".equals(fieldName)) {
    instance.testInt = jsonParser.getValueAsInt();
  } else if ("test_int_obj".equals(fieldName)) {
    instance.testIntObj = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : Integer.valueOf(jsonParser.getValueAsInt());
  } else if ("test_long".equals(fieldName)) {
    instance.testLong = jsonParser.getValueAsLong();
  } else if ("test_long_obj".equals(fieldName)) {
    instance.testLongObj = jsonParser.getCurrentToken() == JsonToken.VALUE_NULL ? null : Long.valueOf(jsonParser.getValueAsLong());
  } else if ("test_string".equals(fieldName)) {
    instance.testString = jsonParser.getValueAsString(null);
  } else if ("test_t".equals(fieldName)) {
    instance.testT = m84ClassJsonMapper.parse(jsonParser);
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:29,代码来源:SimpleGenericModelWithExtends$$JsonObjectMapper.java

示例11: deserialize

import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
public static CallMessage deserialize(JsonParser jp) throws IOException {
	jp.nextToken();
	long request = jp.getLongValue();

	boolean discloseMe = false;
	jp.nextToken();
	Map<String, Object> options = ParserUtil.readObject(jp);
	if (options != null) {
		discloseMe = (boolean) options.getOrDefault("disclose_me", false);
	}

	jp.nextToken();
	String procedure = jp.getValueAsString();

	List<Object> arguments = null;
	JsonToken token = jp.nextToken();
	if (token == JsonToken.START_ARRAY) {
		arguments = ParserUtil.readArray(jp);
	}

	Map<String, Object> argumentsKw = null;
	token = jp.nextToken();
	if (token == JsonToken.START_OBJECT) {
		argumentsKw = ParserUtil.readObject(jp);
	}

	return new CallMessage(request, procedure, arguments, argumentsKw, discloseMe);
}
 
开发者ID:ralscha,项目名称:wamp2spring,代码行数:29,代码来源:CallMessage.java

示例12: deserialize

import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
@Override
public Profile deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
  if (p.getCurrentToken() == JsonToken.VALUE_STRING) {
    if (isImageApiProfile(p.getValueAsString())) {
      return new ImageApiProfile(p.getValueAsString());
    } else {
      return new Profile(URI.create(p.getValueAsString()));
    }
  } else if (p.getCurrentToken() == JsonToken.START_OBJECT) {
    return p.getCodec().readValue(p, ImageApiProfile.class);
  } else {
    return (Profile) defaultDeserializer.deserialize(p, ctxt);
  }
}
 
开发者ID:dbmdz,项目名称:iiif-apis,代码行数:15,代码来源:ProfileDeserializer.java

示例13: parseField

import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
@Override
protected void parseField(String fieldName, JsonParser parser) throws IOException {
    switch (fieldName) {
        case "order_id":
            parser.nextToken();
            orderId = parser.getValueAsString();
            break;
        case "remaining_size":
            parser.nextToken();
            remainingSize = new BigDecimal(parser.getValueAsString());
            break;
        default:
            break;
    }
}
 
开发者ID:cloudwall,项目名称:libcwfincore,代码行数:16,代码来源:MutableOrderOpenEvent.java

示例14: deserialize

import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
@Override
public Type deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
  String enumStr = p.getValueAsString();
  Type type = TYPES.get(enumStr.toLowerCase());
  if(type != null){
    return type;
  }
  logger.debug("Dremio is unable to consume the field type {}, hiding from schema.", enumStr);
  return ElasticMappingSet.Type.UNKNOWN;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:11,代码来源:ElasticTypeDeserializer.java

示例15: parseFieldName

import com.fasterxml.jackson.core.JsonParser; //导入方法依赖的package包/类
private static void parseFieldName(JsonParser jsonParser, JsonParsingContext parsingContext) throws IOException {
    switch (jsonParser.getCurrentName()) {
        case NodeGenericMetadataJsonSerializer.TYPE:
            jsonParser.nextToken();
            parsingContext.type = jsonParser.getValueAsString();
            break;

        case NodeGenericMetadataJsonSerializer.NAME:
            jsonParser.nextToken();
            parsingContext.name = jsonParser.getValueAsString();
            break;

        case NodeGenericMetadataJsonSerializer.VALUE:
            Objects.requireNonNull(parsingContext.name);
            Objects.requireNonNull(parsingContext.type);
            jsonParser.nextToken();
            switch (parsingContext.type) {
                case NodeGenericMetadataJsonSerializer.STRING:
                    parsingContext.metadata.setString(parsingContext.name, jsonParser.getValueAsString());
                    break;
                case NodeGenericMetadataJsonSerializer.DOUBLE:
                    parsingContext.metadata.setDouble(parsingContext.name, jsonParser.getValueAsDouble());
                    break;
                case NodeGenericMetadataJsonSerializer.INT:
                    parsingContext.metadata.setInt(parsingContext.name, jsonParser.getValueAsInt());
                    break;
                case NodeGenericMetadataJsonSerializer.BOOLEAN:
                    parsingContext.metadata.setBoolean(parsingContext.name, jsonParser.getValueAsBoolean());
                    break;
                default:
                    throw new AssertionError("Unexpected metadata type " + parsingContext.type);
            }
            break;

        default:
            throw new AssertionError("Unexpected field: " + jsonParser.getCurrentName());

    }
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:40,代码来源:NodeGenericMetadataJsonDeserializer.java


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