org.codehaus.jackson.JsonNode.iterator()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(139)

本文整理了Java中org.codehaus.jackson.JsonNode.iterator()方法的一些代码示例,展示了JsonNode.iterator()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonNode.iterator()方法的具体详情如下:
包路径:org.codehaus.jackson.JsonNode
类名称:JsonNode
方法名:iterator

JsonNode.iterator介绍

[英]Same as calling #getElements; implemented so that convenience "for-each" loop can be used for looping over elements of JSON Array constructs.
[中]与调用#getElements相同;实现后,方便的“for each”循环可用于在JSON数组构造的元素上循环。

代码示例

代码示例来源:origin: neo4j/neo4j

private static boolean containsError( HTTP.Response response ) throws JsonParseException
  {
    return response.get( "errors" ).iterator().hasNext();
  }
}

代码示例来源:origin: neo4j/neo4j

@Override
protected boolean matchesSafely( HTTP.Response response )
{
  try
  {
    JsonNode list = TransactionMatchers.getJsonNodeWithName( response, "rest" ).iterator().next();
    assertThat( list.get( 0 ).get( "metadata" ).get( "deleted" ).asBoolean(), equalTo( Boolean.TRUE ) );
    assertThat( list.get( 1 ).get( "someKey" ).get( "metadata" ).get( "deleted" ).asBoolean(),
        equalTo( Boolean.TRUE ) );
    return true;
  }
  catch ( JsonParseException e )
  {
    return false;
  }
}

代码示例来源:origin: neo4j/neo4j

@Override
protected boolean matchesSafely( HTTP.Response response )
{
  try
  {
    Iterator<JsonNode> relationships = getJsonNodeWithName( response, "graph" ).get( "relationships" ).iterator();
    for ( int i = 0; i < amount; ++i )
    {
      assertTrue( relationships.hasNext() );
      JsonNode node = relationships.next();
      assertThat( node.get( "deleted" ).asBoolean(), equalTo( Boolean.TRUE ) );
    }
    if ( relationships.hasNext() )
    {
      JsonNode node = relationships.next();
      fail( "Expected no more nodes, but got a node with id " + node.get( "id" ) );
    }
    return true;
  }
  catch ( JsonParseException e )
  {
    return false;
  }
}

代码示例来源:origin: neo4j/neo4j

@Override
protected boolean matchesSafely( HTTP.Response response )
{
  try
  {
    Iterator<JsonNode> entities = getJsonNodeWithName( response, "rest" ).iterator();
    for ( int i = 0; i < amount; ++i )
    {
      assertTrue( entities.hasNext() );
      JsonNode node = entities.next();
      assertThat( node.get( "metadata" ).get( "deleted" ).asBoolean(), equalTo( Boolean.TRUE ) );
    }
    if ( entities.hasNext() )
    {
      fail( "Expected no more entities" );
    }
    return true;
  }
  catch ( JsonParseException e )
  {
    return false;
  }
}

代码示例来源:origin: neo4j/neo4j

@Override
protected boolean matchesSafely( HTTP.Response response )
{
  try
  {
    Iterator<JsonNode> nodes = getJsonNodeWithName( response, "graph" ).get( "nodes" ).iterator();
    int deleted = 0;
    while ( nodes.hasNext() )
    {
      JsonNode node = nodes.next();
      if ( node.get( "deleted" ) != null )
      {
        assertTrue( node.get( "deleted" ).asBoolean() );
        deleted++;
      }
    }
    assertEquals( format( "Expected to see %d deleted elements but %d was encountered.", amount, deleted ),
        amount, deleted );
    return true;
  }
  catch ( JsonParseException e )
  {
    return false;
  }
}

代码示例来源:origin: neo4j/neo4j

@Override
protected boolean matchesSafely( HTTP.Response response )
{
  try
  {
    Iterator<JsonNode> meta = getJsonNodeWithName( response, "meta" ).iterator();
    for ( int metaIndex = 0; meta.hasNext(); metaIndex++ )
    {
      JsonNode node = meta.next();
      if ( metaIndex == index )
      {
        assertTrue( node.isArray() );
      }
    }
    return true;
  }
  catch ( JsonParseException e )
  {
    return false;
  }
}

代码示例来源:origin: neo4j/neo4j

@Override
protected boolean matchesSafely( HTTP.Response response )
{
  try
  {
    Iterator<JsonNode> errors = response.get( "errors" ).iterator();
    Iterator<Status> expected = iterator( expectedErrors );
    while ( expected.hasNext() )
    {
      assertTrue( errors.hasNext() );
      assertThat( errors.next().get( "code" ).asText(), equalTo( expected.next().code().serialize() ) );
    }
    if ( errors.hasNext() )
    {
      JsonNode error = errors.next();
      fail( "Expected no more errors, but got " + error.get( "code" ) + " - '" + error.get( "message" ) + "'." );
    }
    return true;
  }
  catch ( JsonParseException e )
  {
    return false;
  }
}

代码示例来源:origin: neo4j/neo4j

Iterator<JsonNode> meta = getJsonNodeWithName( response, "meta" ).iterator();

代码示例来源:origin: neo4j/neo4j

Iterator<JsonNode> meta = getJsonNodeWithName( response, "meta" ).iterator();

代码示例来源:origin: neo4j/neo4j

times++;
while ( response.get( "errors" ).iterator().hasNext() && (times < 5) );

代码示例来源:origin: neo4j/neo4j

Iterator<JsonNode> meta = getJsonNodeWithName( response, "meta" ).iterator();

代码示例来源:origin: youseries/urule

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;
}

代码示例来源:origin: youseries/urule

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;
}

代码示例来源:origin: youseries/urule

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;
}
public static Value parseValueNode(JsonNode valueNode){

代码示例来源:origin: youseries/urule

JsonNode nodes=node.get("actions");
if(nodes==null)return actions;
Iterator<JsonNode> iter=nodes.iterator();
while(iter.hasNext()){
  JsonNode jsonNode=iter.next();

代码示例来源:origin: com.atlassian.jira/jira-core

public Iterator<ReadOnlyJsonNode> iterator()
{
  return unmodifiableIterator(transform(delegate.iterator(), WrappingFunction.INSTANCE));
}

代码示例来源:origin: org.jboss.seam.social/seam-social-facebook

private <T> List<T> deserializeList(JsonNode jsonNode, String postType, Class<T> type) {
  JsonNode dataNode = jsonNode.get("data");
  List<T> posts = new ArrayList<T>();
  for (Iterator<JsonNode> iterator = dataNode.iterator(); iterator.hasNext();) {
    posts.add(deserializePost(postType, type, (ObjectNode) iterator.next()));
  }
  return posts;
}

代码示例来源:origin: com.github.spullara.mustache.java/jackson-support

@Override
public Iterator iterate(Object object) {
 if (object instanceof JsonNode) {
  JsonNode jn = (JsonNode) object;
  if (jn.isArray()) {
   return jn.iterator();
  }
  return new SingleValueIterator(jn);
 }
 return super.iterate(object);
}

代码示例来源:origin: sirensolutions/siren

private void convertTetheredCable(final JsonNode obj) {
 final Iterator<JsonNode> nodes = obj.path("Connector").iterator();
 while (nodes.hasNext()) {
  final ObjectNode node = (ObjectNode) nodes.next();
  final JsonNode current = node.path("TetheredCable");
  if (!current.isMissingNode() && !current.isNull()) {
   final int value = Integer.parseInt(current.asText());
   node.put("TetheredCable", value);
  }
  if (current.isNull()) {
   node.remove("TetheredCable");
  }
 }
}

代码示例来源:origin: rdelbru/SIREn

private void convertRatedOutputVoltage(final JsonNode obj) {
 final Iterator<JsonNode> nodes = obj.path("Connector").iterator();
 while (nodes.hasNext()) {
  final ObjectNode node = (ObjectNode) nodes.next();
  final JsonNode current = node.path("RatedOutputVoltage");
  if (!current.isMissingNode() && !current.isNull()) {
   final int value = Integer.parseInt(current.asText());
   node.put("RatedOutputVoltage", value);
  }
  if (current.isNull()) {
   node.remove("RatedOutputVoltage");
  }
 }
}

相关文章