本文整理匯總了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()});
}
}
}
示例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();
}
}
示例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
}
示例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();
}
}
示例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;
}
示例6: doMapNext
private long doMapNext() throws IOException {
if (in.getCurrentToken() == JsonToken.END_OBJECT) {
in.nextToken();
advance(Symbol.MAP_END);
return 0;
} else {
return 1;
}
}
示例7: doMapNext
private long doMapNext() throws IOException {
if (in.getCurrentToken() == JsonToken.END_OBJECT) {
in.nextToken();
advance(Symbol.MAP_END);
return 0;
} else {
return 1;
}
}
示例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
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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();
}
}
}
示例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);
}
}
}