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


Java JsonNode.has方法代码示例

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


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

示例1: deserialize

import org.codehaus.jackson.JsonNode; //导入方法依赖的package包/类
@Override
public Window deserialize(JsonParser jp, DeserializationContext dc) throws IOException, JsonProcessingException {
    JsonNode node = jp.getCodec().readTree(jp);
    
    Double value = node.get("value").asDouble();
    Window window = new Window(value);
    
    if (node.has("bounds")) {
        long lowerBound = node.get("bounds").get(0).asLong();
        long upperBound = node.get("bounds").get(1).asLong();
        
        window.withLowerBound(lowerBound).withUpperBound(upperBound);
    }

    return window;
}
 
开发者ID:PyroclastIO,项目名称:pyroclast-java,代码行数:17,代码来源:WindowDeserializer.java

示例2: getAzkabanSessionId

import org.codehaus.jackson.JsonNode; //导入方法依赖的package包/类
/**
 *
 * @param username
 * @param password
 * @return a session id string
 * @throws java.io.IOException
 */
public String getAzkabanSessionId(String username, String password)
  throws Exception {

  Map<String, String> params = new HashMap<>();
  params.put("action", "login");
  params.put("username", username);
  params.put("password", password);
  String response = sendRequest(AZKABAN_URL, params, "post");

  JsonNode obj = jsonReader.readTree(response);
  String sessionId = "";
  if (obj.has("status") && obj.get("status").asText().equals("success")) {
    sessionId = obj.get("session.id").asText();
  } else {
    logger.error("log in failed, user name : {}", username);
    // throw exception
    throw new Exception("username/password wrong. user : " + username);
  }
  this.sessionId = sessionId;

  return sessionId;
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:30,代码来源:AzServiceCommunicator.java

示例3: parseJsonHelper

import org.codehaus.jackson.JsonNode; //导入方法依赖的package包/类
/**
 * Recursively process the execution info to get {@AzkabanJobExecRecord}
 * @param allJobs JsonNode in "nodes" field
 * @param flowExecId
 * @param flowPath Format : project_name:first_level_flow/sub_flow/sub_flow
 * @return
 */
private List<AzkabanJobExecRecord> parseJsonHelper(JsonNode allJobs, long flowExecId, String flowPath) {
  List<AzkabanJobExecRecord> results = new ArrayList<>();
  for (JsonNode oneJob : allJobs) {
    if (oneJob.has("nodes")) { // is a subflow
      String subFlowName = oneJob.get("id").asText();
      flowPath += "/" + subFlowName;
      results.addAll(parseJsonHelper(oneJob.get("nodes"), flowExecId, flowPath));
    } else {
      String jobName = oneJob.get("id").asText();
      long startTime = oneJob.get("startTime").asLong();
      long endTime = oneJob.get("endTime").asLong();
      String status = oneJob.get("status").asText();
      AzkabanJobExecRecord azkabanJobExecRecord =
          new AzkabanJobExecRecord(appId, jobName, flowExecId, (int) (startTime / 1000), (int) (endTime / 1000),
              status, flowPath);
      results.add(azkabanJobExecRecord);
    }
  }
  return results;
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:28,代码来源:AzJobChecker.java

示例4: deserialize

import org.codehaus.jackson.JsonNode; //导入方法依赖的package包/类
@Override
public TopicRecord deserialize(JsonParser jp, DeserializationContext dc) throws IOException, JsonProcessingException {
    JsonNode node = jp.getCodec().readTree(jp);
    
    String topic = node.get("topic").asText();
    long partition = node.get("partition").asLong();
    long offset = node.get("offset").asLong();
    long timestamp = node.get("timestamp").asLong();
    
    String key = null;
    if (node.has("key")) {
        key = node.get("key").asText();
    }
    
    Map<Object, Object> value = new ObjectMapper().readValue(node.get("value").toString(), Map.class);
    return new TopicRecord(topic, key, partition, offset, timestamp, value);
}
 
开发者ID:PyroclastIO,项目名称:pyroclast-java,代码行数:18,代码来源:TopicRecordDeserializer.java

示例5: deserialize

import org.codehaus.jackson.JsonNode; //导入方法依赖的package包/类
@Override
public SubscribeToTopicResult deserialize(JsonParser jp, DeserializationContext dc) throws IOException, JsonProcessingException {
    JsonNode node = jp.getCodec().readTree(jp);
    boolean success = false;
    String reason = null;
    
    if (node.has("subscribed")) {
        success = node.get("subscribed").asBoolean();
    }
    
    if (node.has("reason")) {
        reason = node.get("reason").asText();
    }

    return new SubscribeToTopicResult(success, reason);
}
 
开发者ID:PyroclastIO,项目名称:pyroclast-java,代码行数:17,代码来源:SubscribeToTopicResponseDeserializer.java

示例6: isSessionExpired

import org.codehaus.jackson.JsonNode; //导入方法依赖的package包/类
private boolean isSessionExpired(String response)
  throws IOException {
  JsonNode json = jsonReader.readTree(response);
  if (json.has("error") && json.get("error").asText().equals("session")) {
    logger.error("session expired");
    return true;
  }
  return false;
}
 
开发者ID:thomas-young-2013,项目名称:wherehowsX,代码行数:10,代码来源:AzServiceCommunicator.java

示例7: deserialize

import org.codehaus.jackson.JsonNode; //导入方法依赖的package包/类
@Override
public ProducedEventResult deserialize(JsonParser jp, DeserializationContext dc) throws IOException, JsonProcessingException {
    JsonNode node = jp.getCodec().readTree(jp);
    boolean created = node.get("created").asBoolean();
   
    String reason = null;
    if (node.has("reason")) {
        reason = node.get("reason").asText();
    }
    
    return new ProducedEventResult(created, reason);
}
 
开发者ID:PyroclastIO,项目名称:pyroclast-java,代码行数:13,代码来源:ProduceEventResponseDeserializer.java

示例8: deserialize

import org.codehaus.jackson.JsonNode; //导入方法依赖的package包/类
@Override
public ReadCommitResult deserialize(JsonParser jp, DeserializationContext dc) throws IOException, JsonProcessingException {
    JsonNode node = jp.getCodec().readTree(jp);
    boolean created = node.get("created").asBoolean();

    String reason = null;
    if (node.has("reason")) {
        reason = node.get("reason").asText();
    }

    return new ReadCommitResult(created, reason);
}
 
开发者ID:PyroclastIO,项目名称:pyroclast-java,代码行数:13,代码来源:ReadCommitResponseDeserializer.java

示例9: createFeatureWithOID

import org.codehaus.jackson.JsonNode; //导入方法依赖的package包/类
private String createFeatureWithOID(JsonNode feature, String oid) throws IOException
{
	JsonNode attributes = feature.get("attributes");
	String oidField = "objectId";
	if (attributes.has(oidField))
		((ObjectNode) attributes).remove(oidField);
	if (oid != null)
		((ObjectNode) attributes).put(oidField, Integer.parseInt(oid));
	String newFeatureString = mapper.writeValueAsString(feature);
	return newFeatureString;
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:12,代码来源:MLOBIOutboundTransport.java

示例10: performTheUpdateOperations

import org.codehaus.jackson.JsonNode; //导入方法依赖的package包/类
private void performTheUpdateOperations(List<String> featureList) throws IOException
{
	while (featureList.size() > maxTransactionSize)
		performTheUpdateOperations(featureList.subList(0, maxTransactionSize));

	String responseString = performTheUpdate(featureList);
	try
	{
		validateResponse(responseString);
	}
	catch (Exception e1)
	{
		if (responseString == null)
		{
			LOGGER.error("UPDATE_FAILED_NULL_RESPONSE");
		}
		else
		{
			LOGGER.debug("UPDATE_FAILED_WITH_RESPONSE", responseString);
			List<String> updatedFeatureList = cleanStaleOIDsFromOIDCache(featureList);
			responseString = performTheUpdate(updatedFeatureList);
			try
			{
				validateResponse(responseString);
			}
			catch (Exception e2)
			{
				LOGGER.error(responseString);
				LOGGER.error("FS_WRITE_ERROR", featureService, e2.getMessage());
			}
		}
	}
	LOGGER.debug("RESPONSE_HEADER_MSG", responseString);
	if (responseString != null)
	{
		JsonNode response = mapper.readTree(responseString);
		if (response.has("updateResults"))
		{
			for (JsonNode result : response.get("updateResults"))
			{
				if (result.get("success").asBoolean() == false)
				{
					int errorCode = result.get("error").get("code").asInt();
					if (errorCode == 1011 || errorCode == 1019)
					{
						String trackID = moveOIDToInsertList(result.get("objectId").asText(), features);
						LOGGER.debug("UPDATE_FAILED_TRY_INSERT_MSG", errorCode, trackID);
					}
				}
			}
		}
	}
	featureList.clear();
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:55,代码来源:MLOBIOutboundTransport.java

示例11: performMissingOIDQuery

import org.codehaus.jackson.JsonNode; //导入方法依赖的package包/类
private void performMissingOIDQuery(String whereString) throws IOException
{
	Collection<KeyValue> params = new ArrayList<KeyValue>();
	
	params.add(new KeyValue("f", "json"));
	params.add(new KeyValue("outfields", trackIDField + "," + "objectId"));
	params.add(new KeyValue("returnGeometry", "false"));
	params.add(new KeyValue("where", whereString));
	clientUrl = host + "/rest/services/" + featureService + "/FeatureServer/" + layerIndex + "/query";
	URL url = new URL(clientUrl);
	if (LOGGER.isDebugEnabled())
		LOGGER.debug("URL_POST_DEBUG", url, paramsToString(params));
	//String responseString = postAndGetReply(url, params);
	String responseString = executeGetAndGetReply(url, params);
	try
	{
		validateResponse(responseString);
	}
	catch (IOException ex)
	{
		LOGGER.error("URL_POST_ERROR", ex, url, paramsToString(params));
		throw ex;
	}
	LOGGER.debug("RESPONSE_HEADER_MSG", responseString);
	JsonNode response = mapper.readTree(responseString);
	if (!response.has("features"))
		return;
	for (JsonNode feature : response.get("features"))
	{
		JsonNode attributes = feature.get("attributes");
		String oid = String.valueOf(attributes.get("objectId"));
		// String trackID = attributes.get(trackIDField).getTextValue();
		JsonNode tidNode = attributes.get("trackid");
		String trackID = getTrackIdAsString(tidNode);

		if (trackID != null)
		{
			oidCache.put(trackID, oid);
		}
	}
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:42,代码来源:MLOBIOutboundTransport.java

示例12: moveOIDToInsertList

import org.codehaus.jackson.JsonNode; //导入方法依赖的package包/类
private String moveOIDToInsertList(String objectId, JsonNode features) throws IOException
{
	for (JsonNode feature : features)
	{
		JsonNode attributes = feature.get("attributes");
		if (attributes.has(trackIDField) && attributes.has("objectId"))
		{
			String trackID = attributes.get(trackIDField).asText();
			String oid = attributes.get("objectId").asText();
			if (oid != null && oid.equals(objectId))
			{
				((ObjectNode) attributes).remove("objectId");
				if (oidCache.containsKey(trackID))
					oidCache.remove(trackID);
				insertFeatureList.add(mapper.writeValueAsString(feature));
				return trackID;
			}
		}
	}
	return null;
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:22,代码来源:MLOBIOutboundTransport.java


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