當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。