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