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


Java JsonNode.findValue方法代码示例

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


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

示例1: getEventFromJson

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
 * Parse an object node in order to create an {@link Event} object
 *
 * @param objectNode object node to convert to {@link Event}
 * @return {@link Event} converted format
 * @see TwitterMock#SOURCE
 */
@Override
public Event getEventFromJson(ObjectNode objectNode) {
    Date startDate = Date.from(Instant.ofEpochMilli(objectNode.findValue("timestamp_ms").asLong()));
    Date endDate = Date.from(Instant.now());
    JsonNode jsonNode = objectNode.findValue("place");
    JsonNode jsonCoordinates = jsonNode.findValue("coordinates");
    String description = objectNode.findValue("text").toString();
    LatLong latLong = jsonToLatLong(jsonCoordinates);
    try {
        return new Event(latLong, startDate, endDate, description, SOURCE);
    } catch (IllegalArgumentException | NullPointerException err) {
        LOGGER.error(err.getMessage());
        return null;
    }
}
 
开发者ID:IKB4Stream,项目名称:IKB4Stream,代码行数:23,代码来源:TwitterMock.java

示例2: apply

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
@Override
public JDefinedClass apply(String nodeName, JsonNode node, JDefinedClass jclass, Schema schema) {
    List<String> requiredFieldMethods = new ArrayList<String>();

    JsonNode properties = schema.getContent().get("properties");

    for (Iterator<JsonNode> iterator = node.elements(); iterator.hasNext(); ) {
        String requiredArrayItem = iterator.next().asText();
        if (requiredArrayItem.isEmpty()) {
            continue;
        }

        JsonNode propertyNode = null;

        if (properties != null) {
            propertyNode = properties.findValue(requiredArrayItem);
        }

        String fieldName = ruleFactory.getNameHelper().getPropertyName(requiredArrayItem, propertyNode);
        JFieldVar field = jclass.fields().get(fieldName);

        if (field == null) {
            continue;
        }

        addJavaDoc(field);

        if (ruleFactory.getGenerationConfig().isIncludeJsr303Annotations()) {
            addNotNullAnnotation(field);
        }

        if (ruleFactory.getGenerationConfig().isIncludeJsr305Annotations()) {
            addNonnullAnnotation(field);
        }

        requiredFieldMethods.add(getGetterName(fieldName, field.type(), node));
        requiredFieldMethods.add(getSetterName(fieldName, node));
    }

    updateGetterSetterJavaDoc(jclass, requiredFieldMethods);

    return jclass;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:44,代码来源:RequiredArrayRule.java

示例3: extractAttributesFromResourceAsJson

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private String extractAttributesFromResourceAsJson(Resource resource) throws IOException {

		JsonApiResponse response = new JsonApiResponse();
		response.setEntity(resource);
		// deserialize using the objectMapper so it becomes json-api
		String newRequestBody = objectMapper.writeValueAsString(resource);
		JsonNode node = objectMapper.readTree(newRequestBody);
		JsonNode attributes = node.findValue("attributes");
		return objectMapper.writeValueAsString(attributes);

	}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:12,代码来源:ResourcePatch.java

示例4: jsonToLatLong

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
/**
 * Parse a json node object in order to create a valid {@link LatLong} object
 *
 * @param objectNode {@link LatLong} in JSON format
 * @return a valid {@link LatLong}
 * @see LatLong
 * @see DBpediaMock#VALUE
 */
private static LatLong jsonToLatLong(JsonNode objectNode) {
    JsonNode latitudeNode = objectNode.findValue("latitude");
    JsonNode longitudeNode = objectNode.findValue("longitude");
    if (latitudeNode != null && longitudeNode != null) {
        double latitude = latitudeNode.findValue(VALUE).asDouble();
        double longitude = longitudeNode.findValue(VALUE).asDouble();
        return new LatLong(latitude, longitude);
    }
    return null;
}
 
开发者ID:IKB4Stream,项目名称:IKB4Stream,代码行数:19,代码来源:DBpediaMock.java

示例5: doGetEC2InstanceRegion

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
static String doGetEC2InstanceRegion(final String json) {
    if (null != json) {
        try {
            JsonNode node = MAPPER.readTree(json.getBytes(StringUtils.UTF8));
            JsonNode region = node.findValue(REGION);
            return region.asText();
        } catch (Exception e) {
            log.warn("Unable to parse EC2 instance info (" + json
                     + ") : " + e.getMessage(), e);
        }
    }
    return null;
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:14,代码来源:EC2MetadataUtils.java

示例6: doGetEC2InstanceRegion

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
static String doGetEC2InstanceRegion(final String json) {
    if (null != json) {
        try {
            JsonNode node = mapper.readTree(json.getBytes(StringUtils.UTF8));
            JsonNode region = node.findValue(REGION);
            return region.asText();
        } catch (Exception e) {
            log.warn("Unable to parse EC2 instance info (" + json
                    + ") : " + e.getMessage(), e);
        }
    }
    return null;
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:14,代码来源:EC2MetadataUtils.java

示例7: parse

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private static C4CTicket parse(String content) throws JsonProcessingException, IOException, C4CTicketNotFoundException {
	ObjectMapper mapper = new ObjectMapper();
	JsonNode jNode = mapper.readTree(content);
	JsonNode resultsArray = jNode.findValue(RESULTS_JSON_TREE_NODE);
	if(resultsArray.isNull() || !resultsArray.elements().hasNext()){
		throw new C4CTicketNotFoundException();
	}
	
	C4CTicket c4cTicket = createC4CTicketObject(jNode);
	return c4cTicket;
}
 
开发者ID:SAP,项目名称:cloud-c4c-ticket-duplicate-finder-ext,代码行数:12,代码来源:C4CTicketService.java

示例8: isNotNull

import com.fasterxml.jackson.databind.JsonNode; //导入方法依赖的package包/类
private boolean isNotNull(JsonNode jsonNode, String field){
	
	return jsonNode.findValue(field) != null && !jsonNode.get(field).isNull();
}
 
开发者ID:wesley-ramos,项目名称:spring-multitenancy,代码行数:5,代码来源:TenantStrategyJson.java


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