當前位置: 首頁>>代碼示例>>Java>>正文


Java JsonToken.END_OBJECT屬性代碼示例

本文整理匯總了Java中org.codehaus.jackson.JsonToken.END_OBJECT屬性的典型用法代碼示例。如果您正苦於以下問題:Java JsonToken.END_OBJECT屬性的具體用法?Java JsonToken.END_OBJECT怎麽用?Java JsonToken.END_OBJECT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.codehaus.jackson.JsonToken的用法示例。


在下文中一共展示了JsonToken.END_OBJECT屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: parse

public void parse(HttpRequest req) throws IOException {

      final JsonParser parser = jsonFactory.createJsonParser(
              new ChannelBufferInputStream(req.getContent()));

      parser.nextToken(); // Skip the wrapper

      while (parser.nextToken() != JsonToken.END_OBJECT) {

        final String metric = parser.getCurrentName();

        JsonToken currentToken = parser.nextToken();
        if (currentToken == JsonToken.START_OBJECT) {
          parseMetricObject(metric, parser);
        } else if (currentToken == JsonToken.START_ARRAY) {
          int illegalTokens = parseMetricArray(metric, parser);
          if(illegalTokens > 0) {
              logger.warn("{} illegal tokens encountered", illegalTokens);
          }
        } else {
          logger.warn("Illegal token: expected {} or {}, but was {}: {}",new Object[] {
                  JsonToken.START_OBJECT, JsonToken.START_ARRAY, currentToken, parser.getText()});
        }
      }
    }
 
開發者ID:yandex,項目名稱:opentsdb-flume,代碼行數:25,代碼來源:LegacyHttpSource.java

示例2: readGrants

/**
 * Reads the list of grants from the JSON stream
 *  @param coronaSerializer The CoronaSerializer instance being used to read
 *                          the JSON from disk
 * @throws IOException
 */
private void readGrants(CoronaSerializer coronaSerializer)
  throws IOException {
  // Expecting the START_OBJECT token for grants
  coronaSerializer.readStartObjectToken("grants");
  JsonToken current = coronaSerializer.nextToken();
  while (current != JsonToken.END_OBJECT) {
    // We can access the key for the grant, but it is not required
    // Expecting the START_OBJECT token for the grant
    coronaSerializer.readStartObjectToken("grant");

    coronaSerializer.readField("grantId");
    GrantId grantId = new GrantId(coronaSerializer);
    coronaSerializer.readField("grant");
    ResourceRequestInfo resourceRequestInfo =
      new ResourceRequestInfo(coronaSerializer);

    // Expecting the END_OBJECT token for the grant
    coronaSerializer.readEndObjectToken("grant");

    // This will update the grants map and the resourceTypeToStatsMap map
    addGrant(grantId.getSessionId(), resourceRequestInfo);

    current = coronaSerializer.nextToken();
  }
}
 
開發者ID:rhli,項目名稱:hadoop-EAR,代碼行數:31,代碼來源:ClusterNode.java

示例3: readNameToNode

/**
 * Reads the nameToNode map from the JSON stream
 * @param coronaSerializer The CoronaSerializer instance to be used to
 *                         read the JSON
 * @throws IOException
 */
private void readNameToNode(CoronaSerializer coronaSerializer)
  throws IOException {
  coronaSerializer.readField("nameToNode");
  // Expecting the START_OBJECT token for nameToNode
  coronaSerializer.readStartObjectToken("nameToNode");
  JsonToken current = coronaSerializer.nextToken();
  while (current != JsonToken.END_OBJECT) {
    // nodeName is the key, and the ClusterNode is the value here
    String nodeName = coronaSerializer.getFieldName();
    ClusterNode clusterNode = new ClusterNode(coronaSerializer);
    if (!nameToNode.containsKey(nodeName)) {
      nameToNode.put(nodeName, clusterNode);
    }
    current = coronaSerializer.nextToken();
  }
  // Done with reading the END_OBJECT token for nameToNode
}
 
開發者ID:rhli,項目名稱:hadoop-EAR,代碼行數:23,代碼來源:NodeManager.java

示例4: readNameToApps

/**
 * Reads the nameToApps map from the JSON stream
 * @param coronaSerializer The CoronaSerializer instance to be used to
 *                         read the JSON
 * @throws IOException
 */
private void readNameToApps(CoronaSerializer coronaSerializer)
  throws IOException {
  coronaSerializer.readField("nameToApps");
  // Expecting the START_OBJECT token for nameToApps
  coronaSerializer.readStartObjectToken("nameToApps");
  JsonToken current = coronaSerializer.nextToken();

  while (current != JsonToken.END_OBJECT) {
    String nodeName = coronaSerializer.getFieldName();
    // Expecting the START_OBJECT token for the Apps
    coronaSerializer.readStartObjectToken(nodeName);
    Map<String, String> appMap = coronaSerializer.readValueAs(Map.class);
    Map<ResourceType, String> appsOnNode =
      new HashMap<ResourceType, String>();

    for (Map.Entry<String, String> entry : appMap.entrySet()) {
      appsOnNode.put(ResourceType.valueOf(entry.getKey()),
        entry.getValue());
    }

    nameToApps.put(nodeName, appsOnNode);
    current = coronaSerializer.nextToken();
  }
}
 
開發者ID:rhli,項目名稱:hadoop-EAR,代碼行數:30,代碼來源:NodeManager.java

示例5: getSpecificJSONValue

private String getSpecificJSONValue(HttpResponse response, String jsonKey) throws JsonParseException, IllegalStateException, IOException {
	InputStream content = response.getEntity().getContent();
	if (isSuccessfulResponse(response)) {
		JsonFactory f = new JsonFactory();
		JsonParser jp = f.createJsonParser(content);
		while ((jp.nextToken()) != JsonToken.END_OBJECT) {
			if (jsonKey.equals(jp.getCurrentName())) {
				jp.nextToken();
				return jp.getText();
			}
		}
	} else {
		String string = IOUtils.toString(content);
		System.err.println(string);
	}
	return null;
}
 
開發者ID:ExLibrisGroup,項目名稱:Rosetta.dps-sdk-projects,代碼行數:17,代碼來源:CDMIConnector.java

示例6: doMapNext

private long doMapNext() throws IOException {
	if (in.getCurrentToken() == JsonToken.END_OBJECT) {
		in.nextToken();
		advance(Symbol.MAP_END);
		return 0;
	} else {
		return 1;
	}
}
 
開發者ID:Celos,項目名稱:avro-json-decoder,代碼行數:9,代碼來源:ExtendedJsonDecoder.java

示例7: doMapNext

private long doMapNext() throws IOException {
  if (in.getCurrentToken() == JsonToken.END_OBJECT) {
    in.nextToken();
    advance(Symbol.MAP_END);
    return 0;
  } else {
    return 1;
  }
}
 
開發者ID:openaire,項目名稱:iis,代碼行數:9,代碼來源:HackedJsonDecoder.java

示例8: readIdToRequest

/**
 * Reads the idToRequest map from a JSON stream
 *
 * @param coronaSerializer The CoronaSerializer instance to be used to
 *                         read the JSON
 * @throws IOException
 */
private void readIdToRequest(CoronaSerializer coronaSerializer)
  throws IOException {
  coronaSerializer.readField("idToRequest");
  // Expecting the START_OBJECT token for idToRequest
  coronaSerializer.readStartObjectToken("idToRequest");
  JsonToken current = coronaSerializer.nextToken();
  while (current != JsonToken.END_OBJECT) {
    Integer id = Integer.parseInt(coronaSerializer.getFieldName());
    idToRequest.put(id, new ResourceRequestInfo(coronaSerializer));
    current = coronaSerializer.nextToken();
  }
  // Done with reading the END_OBJECT token for idToRequest
}
 
開發者ID:rhli,項目名稱:hadoop-EAR,代碼行數:20,代碼來源:Session.java

示例9: getResponseMetadata

private HashMap<String, String> getResponseMetadata(HttpResponse response, String identifier) throws JsonParseException, IllegalStateException, IOException {
	HashMap<String, String> metadata = new HashMap<String, String>();
	InputStream content = response.getEntity().getContent();
	if (isSuccessfulResponse(response)) {
		String key, value = null;
		JsonFactory f = new JsonFactory();
		JsonParser jp = f.createJsonParser(content);
		while ((jp.nextToken()) != JsonToken.END_OBJECT) {
			key = jp.getCurrentName();
			if ("metadata".equals(key)) {
				jp.nextToken();
				System.out.println("Start parsing metadata for " + identifier);
				while ((jp.nextToken()) != JsonToken.END_OBJECT) {
					key = jp.getCurrentName();
					jp.nextToken();
					value = jp.getText();
					metadata.put(key, value);
					System.out.println(identifier + " -- Key = " + key + " : Value = " + value);
				}
				System.out.println("End parsing metadata for " + identifier);
				return metadata;
			}
		}
	} else {
		String string = IOUtils.toString(content);
		System.err.println(string);
	}
	return metadata;
}
 
開發者ID:ExLibrisGroup,項目名稱:Rosetta.dps-sdk-projects,代碼行數:29,代碼來源:CDMIConnector.java

示例10: readWorkerStatus

private static WorkerStatus readWorkerStatus(JsonParser jParser) throws IOException {
    WorkerStatus res = new WorkerStatus();

    while (jParser.nextToken() != JsonToken.END_OBJECT) {
        switch (jParser.getCurrentName() + "") {
            case "workerId":
                nextToken(jParser);
                res.setWorkerId(readValue(jParser));
                break;
            case "location":
                nextToken(jParser);
                res.setWorkerLocation(readValue(jParser));
                break;
            case "processId":
                nextToken(jParser);
                res.setProcessId(readValue(jParser));
                break;
            case "status":
                nextToken(jParser);
                res.setStatus(Integer.parseInt(readValue(jParser)));
                break;
            case "lastConnectionTs":
                nextToken(jParser);
                res.setLastConnectionTs(Long.parseLong(readValue(jParser)));
                break;
            default:
                throw new IOException("Unexpected field " + jParser.getCurrentName());
        }
    }

    return res;
}
 
開發者ID:diennea,項目名稱:majordodo,代碼行數:32,代碼來源:BrokerStatusSnapshot.java

示例11: readTransaction

private static Transaction readTransaction(JsonParser jParser) throws IOException {
    long creationTimestamp = 0;
    long id = 0;
    List<Task> preparedTasks = new ArrayList<>();
    while (jParser.nextToken() != JsonToken.END_OBJECT) {

        switch (jParser.getCurrentName() + "") {
            case "creationTimestamp":
                nextToken(jParser);
                creationTimestamp = Long.parseLong(readValue(jParser));
                break;
            case "id":
                nextToken(jParser);
                id = Long.parseLong(readValue(jParser));
                break;
            case "preparedTasks":
                nextToken(jParser);
                while (jParser.nextToken() != JsonToken.END_ARRAY) {
                    Task task = readTask(jParser);
                    preparedTasks.add(task);
                }
                break;
            default:
                throw new IOException("Unexpected field " + jParser.getCurrentName());
        }
    }
    Transaction res = new Transaction(id, creationTimestamp);
    if (!preparedTasks.isEmpty()) {
        res.getPreparedTasks().addAll(preparedTasks);
    }
    return res;

}
 
開發者ID:diennea,項目名稱:majordodo,代碼行數:33,代碼來源:BrokerStatusSnapshot.java

示例12: readCodePool

private static CodePool readCodePool(JsonParser jParser) throws IOException {
    long creationTimestamp = 0;
    String id = "";
    long ttl = 0;
    byte[] payload = null;

    while (jParser.nextToken() != JsonToken.END_OBJECT) {

        switch (jParser.getCurrentName() + "") {
            case "creationTimestamp":
                nextToken(jParser);
                creationTimestamp = Long.parseLong(readValue(jParser));
                break;
            case "ttl":
                nextToken(jParser);
                ttl = Long.parseLong(readValue(jParser));
                break;
            case "id":
                nextToken(jParser);
                id = readValue(jParser);
                break;
            case "data":
                nextToken(jParser);
                String base64data = readValue(jParser);
                payload = Base64.getDecoder().decode(base64data);
                break;

            default:
                throw new IOException("Unexpected field " + jParser.getCurrentName());
        }
    }
    return new CodePool(id, creationTimestamp, payload, ttl);

}
 
開發者ID:diennea,項目名稱:majordodo,代碼行數:34,代碼來源:BrokerStatusSnapshot.java

示例13: findSkipChildren

/**
	 * @param jParser
	 * @param fieldname1
	 * @throws IOException
	 * @throws JsonParseException
	 */
	public static void findSkipChildren(JsonParser jParser) throws IOException, JsonParseException {
		while (jParser.nextToken() != JsonToken.END_OBJECT) {

			String fieldname = jParser.getCurrentName();
			if (fieldname != null && fieldname.contains("children")) {
			 
//				System.out.println("Skipping children");
				jParser.nextToken(); // current token is "[", move next
				jParser.skipChildren();
			}
		}
	}
 
開發者ID:hammyau,項目名稱:ODFExplorer,代碼行數:18,代碼來源:StyleJSONReader.java

示例14: jsonToHostDefinition

protected void jsonToHostDefinition(String json, HostDefinition host) throws IOException {
    MappingJsonFactory f = new MappingJsonFactory();
    JsonParser jp;
    
    try {
        jp = f.createJsonParser(json);
    } catch (JsonParseException e) {
        throw new IOException(e);
    }
    
    jp.nextToken();
    if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
        throw new IOException("Expected START_OBJECT");
    }
    
    while (jp.nextToken() != JsonToken.END_OBJECT) {
        if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
            throw new IOException("Expected FIELD_NAME");
        }
        
        String n = jp.getCurrentName();
        jp.nextToken();
        if (jp.getText().equals("")) 
            continue;
        else if (n.equals("attachment")) {
            while (jp.nextToken() != JsonToken.END_OBJECT) {
                String field = jp.getCurrentName();
                if (field.equals("id")) {
                    host.attachment = jp.getText();
                } else if (field.equals("mac")) {
                    host.mac = jp.getText();
                }
            }
        }
    }
    
    jp.close();
}
 
開發者ID:vishalshubham,項目名稱:Multipath-Hedera-system-in-Floodlight-controller,代碼行數:38,代碼來源:HostResource.java

示例15: findDiffProperties

private static void findDiffProperties(JsonParser jParser) throws JsonParseException, IOException {
		while (jParser.nextToken() != JsonToken.END_OBJECT) {

			String fieldname = jParser.getCurrentName();
			if (fieldname != null && fieldname.contains("children")) {
//				System.out.println("iterating children");
				jParser.nextToken(); // current token is "[", move next
				findDiffProp(jParser);
			}
		}
	}
 
開發者ID:hammyau,項目名稱:ODFExplorer,代碼行數:11,代碼來源:StyleJSONReader.java


注:本文中的org.codehaus.jackson.JsonToken.END_OBJECT屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。