当前位置: 首页>>代码示例>>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;未经允许,请勿转载。