本文整理汇总了Java中org.codehaus.jackson.JsonNode.iterator方法的典型用法代码示例。如果您正苦于以下问题:Java JsonNode.iterator方法的具体用法?Java JsonNode.iterator怎么用?Java JsonNode.iterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.jackson.JsonNode
的用法示例。
在下文中一共展示了JsonNode.iterator方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseParameters
import org.codehaus.jackson.JsonNode; //导入方法依赖的package包/类
public static List<Parameter> parseParameters(JsonNode node){
JsonNode parametersNode=node.get("parameters");
if(parametersNode==null){
return null;
}
Iterator<JsonNode> iter=parametersNode.iterator();
List<Parameter> parameters=new ArrayList<Parameter>();
while(iter.hasNext()){
JsonNode parameterNode=iter.next();
Parameter param=new Parameter();
param.setName(getJsonValue(parameterNode, "name"));
String type=getJsonValue(parameterNode, "type");
if(type!=null){
param.setType(Datatype.valueOf(type));
}
String valueTypeText=getJsonValue(parameterNode, "valueType");
if(valueTypeText!=null){
param.setValue(parseValue(parameterNode));
}
param.setValue(parseValue(parameterNode));
parameters.add(param);
}
return parameters;
}
示例2: parseLines
import org.codehaus.jackson.JsonNode; //导入方法依赖的package包/类
private List<Line> parseLines(JsonNode node){
JsonNode lineNodes=node.get("lines");
if(lineNodes==null){
return null;
}
List<Line> lines=new ArrayList<Line>();
Iterator<JsonNode> iter=lineNodes.iterator();
while(iter.hasNext()){
JsonNode jsonNode=iter.next();
Line line=new Line();
line.setFromNodeId(jsonNode.get("fromNodeId").getIntValue());
line.setToNodeId(jsonNode.get("toNodeId").getIntValue());
lines.add(line);
}
return lines;
}
示例3: parseCriteriaUnit
import org.codehaus.jackson.JsonNode; //导入方法依赖的package包/类
private CriteriaUnit parseCriteriaUnit(JsonNode unitNode) {
CriteriaUnit unit=new CriteriaUnit();
JsonNode criteriaNode=unitNode.get("criteria");
if(criteriaNode!=null){
unit.setCriteria(parseCriteria(criteriaNode));
}
JsonNode junctionTypeNode=unitNode.get("junctionType");
if(junctionTypeNode!=null){
unit.setJunctionType(JunctionType.valueOf(junctionTypeNode.getTextValue()));
}
JsonNode nextUnitNodes=unitNode.get("nextUnits");
if(nextUnitNodes!=null){
List<CriteriaUnit> nextUnits=new ArrayList<CriteriaUnit>();
Iterator<JsonNode> iter=nextUnitNodes.iterator();
while(iter.hasNext()){
JsonNode nextNode=iter.next();
nextUnits.add(parseCriteriaUnit(nextNode));
}
unit.setNextUnits(nextUnits);
}
return unit;
}
示例4: deserialize
import org.codehaus.jackson.JsonNode; //导入方法依赖的package包/类
@Override
public ProducedEventsResult deserialize(JsonParser jp, DeserializationContext dc) throws IOException, JsonProcessingException {
JsonNode node = jp.getCodec().readTree(jp);
if (node.isArray()) {
List<ProducedEventResult> responses = new ArrayList<>();
Iterator<JsonNode> it = node.iterator();
while (it.hasNext()) {
JsonNode n = it.next();
responses.add(new ProducedEventResult(n.get("created").asBoolean()));
}
return new ProducedEventsResult(responses);
} else {
String reason = node.get("reason").asText();
return new ProducedEventsResult(reason);
}
}
示例5: testRMNMInfo
import org.codehaus.jackson.JsonNode; //导入方法依赖的package包/类
@Test
public void testRMNMInfo() throws Exception {
if (!(new File(MiniMRYarnCluster.APPJAR)).exists()) {
LOG.info("MRAppJar " + MiniMRYarnCluster.APPJAR
+ " not found. Not running test.");
return;
}
RMContext rmc = mrCluster.getResourceManager().getRMContext();
ResourceScheduler rms = mrCluster.getResourceManager()
.getResourceScheduler();
RMNMInfo rmInfo = new RMNMInfo(rmc,rms);
String liveNMs = rmInfo.getLiveNodeManagers();
ObjectMapper mapper = new ObjectMapper();
JsonNode jn = mapper.readTree(liveNMs);
Assert.assertEquals("Unexpected number of live nodes:",
NUMNODEMANAGERS, jn.size());
Iterator<JsonNode> it = jn.iterator();
while (it.hasNext()) {
JsonNode n = it.next();
Assert.assertNotNull(n.get("HostName"));
Assert.assertNotNull(n.get("Rack"));
Assert.assertTrue("Node " + n.get("NodeId") + " should be RUNNING",
n.get("State").asText().contains("RUNNING"));
Assert.assertNotNull(n.get("NodeHTTPAddress"));
Assert.assertNotNull(n.get("LastHealthUpdate"));
Assert.assertNotNull(n.get("HealthReport"));
Assert.assertNotNull(n.get("NodeManagerVersion"));
Assert.assertNotNull(n.get("NumContainers"));
Assert.assertEquals(
n.get("NodeId") + ": Unexpected number of used containers",
0, n.get("NumContainers").asInt());
Assert.assertEquals(
n.get("NodeId") + ": Unexpected amount of used memory",
0, n.get("UsedMemoryMB").asInt());
Assert.assertNotNull(n.get("AvailableMemoryMB"));
}
}
示例6: testRMNMInfoMissmatch
import org.codehaus.jackson.JsonNode; //导入方法依赖的package包/类
@Test
public void testRMNMInfoMissmatch() throws Exception {
RMContext rmc = mock(RMContext.class);
ResourceScheduler rms = mock(ResourceScheduler.class);
ConcurrentMap<NodeId, RMNode> map = new ConcurrentHashMap<NodeId, RMNode>();
RMNode node = MockNodes.newNodeInfo(1, MockNodes.newResource(4 * 1024));
map.put(node.getNodeID(), node);
when(rmc.getRMNodes()).thenReturn(map);
RMNMInfo rmInfo = new RMNMInfo(rmc,rms);
String liveNMs = rmInfo.getLiveNodeManagers();
ObjectMapper mapper = new ObjectMapper();
JsonNode jn = mapper.readTree(liveNMs);
Assert.assertEquals("Unexpected number of live nodes:",
1, jn.size());
Iterator<JsonNode> it = jn.iterator();
while (it.hasNext()) {
JsonNode n = it.next();
Assert.assertNotNull(n.get("HostName"));
Assert.assertNotNull(n.get("Rack"));
Assert.assertTrue("Node " + n.get("NodeId") + " should be RUNNING",
n.get("State").asText().contains("RUNNING"));
Assert.assertNotNull(n.get("NodeHTTPAddress"));
Assert.assertNotNull(n.get("LastHealthUpdate"));
Assert.assertNotNull(n.get("HealthReport"));
Assert.assertNotNull(n.get("NodeManagerVersion"));
Assert.assertNull(n.get("NumContainers"));
Assert.assertNull(n.get("UsedMemoryMB"));
Assert.assertNull(n.get("AvailableMemoryMB"));
}
}
示例7: deserialize
import org.codehaus.jackson.JsonNode; //导入方法依赖的package包/类
@Override
public ReadAggregateGroupResult deserialize(JsonParser jp, DeserializationContext dc) throws IOException, JsonProcessingException {
JsonNode node = jp.getCodec().readTree(jp);
ObjectMapper mapper = new ObjectMapper();
String id = node.get("id").asText();
String name = node.get("name").asText();
String type = node.get("type").asText();
String group = node.get("group").asText();
boolean isGrouped = node.get("grouped?").asBoolean();
JsonNode contents = node.get("contents");
List<Window> parsedWindows = new ArrayList<>();
Iterator<JsonNode> it = contents.iterator();
while (it.hasNext()) {
JsonNode n = it.next();
Window window = mapper.readValue(n.toString(), Window.class);
parsedWindows.add(window);
}
Map<String, List<Window>> result = new HashMap<>();
result.put(group, parsedWindows);
DeploymentAggregate da = new DeploymentAggregate(id, type, isGrouped)
.withName(name)
.withGroupedContents(result);
return new ReadAggregateGroupResult(true, da);
}
示例8: deserialize
import org.codehaus.jackson.JsonNode; //导入方法依赖的package包/类
@Override
public PollTopicResult deserialize(JsonParser jp, DeserializationContext dc) throws IOException, JsonProcessingException {
ObjectMapper mapper = new ObjectMapper();
JsonNode node = jp.getCodec().readTree(jp);
List<TopicRecord> records = new ArrayList<>();
Iterator<JsonNode> it = node.iterator();
while (it.hasNext()) {
JsonNode n = it.next();
TopicRecord tr = mapper.readValue(n.toString(), TopicRecord.class);
records.add(tr);
}
return new PollTopicResult(true, records);
}
示例9: parseActions
import org.codehaus.jackson.JsonNode; //导入方法依赖的package包/类
private List<Action> parseActions(JsonNode node){
List<Action> actions=new ArrayList<Action>();
JsonNode nodes=node.get("actions");
if(nodes==null)return actions;
Iterator<JsonNode> iter=nodes.iterator();
while(iter.hasNext()){
JsonNode jsonNode=iter.next();
ActionType actionType=ActionType.valueOf(JsonUtils.getJsonValue(jsonNode, "actionType"));
switch(actionType){
case ConsolePrint:
ConsolePrintAction console=new ConsolePrintAction();
console.setValue(JsonUtils.parseValue(jsonNode));
console.setPriority(Integer.valueOf(JsonUtils.getJsonValue(jsonNode, "priority")));
actions.add(console);
break;
case ExecuteMethod:
ExecuteMethodAction method=new ExecuteMethodAction();
method.setBeanId(JsonUtils.getJsonValue(jsonNode, "beanId"));
method.setBeanLabel(JsonUtils.getJsonValue(jsonNode, "beanLabel"));
method.setMethodLabel(JsonUtils.getJsonValue(jsonNode, "methodLabel"));
method.setPriority(Integer.valueOf(JsonUtils.getJsonValue(jsonNode, "priority")));
method.setMethodName(JsonUtils.getJsonValue(jsonNode, "methodName"));
method.setParameters(JsonUtils.parseParameters(jsonNode));
actions.add(method);
break;
case VariableAssign:
VariableAssignAction assign=new VariableAssignAction();
String type=JsonUtils.getJsonValue(jsonNode, "type");
if(type!=null){
assign.setType(LeftType.valueOf(type));
}
assign.setReferenceName(JsonUtils.getJsonValue(jsonNode, "referenceName"));
assign.setDatatype(Datatype.valueOf(JsonUtils.getJsonValue(jsonNode, "datatype")));
assign.setVariableCategory(JsonUtils.getJsonValue(jsonNode, "variableCategory"));
assign.setVariableLabel(JsonUtils.getJsonValue(jsonNode, "variableLabel"));
assign.setVariableName(JsonUtils.getJsonValue(jsonNode, "variableName"));
assign.setPriority(Integer.valueOf(JsonUtils.getJsonValue(jsonNode, "priority")));
assign.setValue(JsonUtils.parseValue(jsonNode));
actions.add(assign);
break;
case ExecuteCommonFunction:
ExecuteCommonFunctionAction ca=new ExecuteCommonFunctionAction();
ca.setLabel(JsonUtils.getJsonValue(jsonNode, "label"));
ca.setName(JsonUtils.getJsonValue(jsonNode, "name"));
ca.setParameter(JsonUtils.parseCommonFunctionParameter(jsonNode));
ca.setPriority(Integer.valueOf(JsonUtils.getJsonValue(jsonNode, "priority")));
actions.add(ca);
break;
case Scoring:
int rowNumber=Integer.valueOf(JsonUtils.getJsonValue(jsonNode, "rowNumber"));
String name=JsonUtils.getJsonValue(jsonNode, "name");
String weight=JsonUtils.getJsonValue(jsonNode, "weight");
ScoringAction sa=new ScoringAction(rowNumber, name, weight);
sa.setValue(JsonUtils.parseValue(jsonNode));
actions.add(sa);
break;
}
}
return actions;
}