Uploaded image for project: 'Commons JXPath'
  1. Commons JXPath
  2. JXPATH-168

Iterator on JSON skips nodes that have a "false" property

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.3
    • None
    • Java 1.7

    Description

      We have a JSON response, that has some properties that have a value of "false", but other properties are OK. When iterating on all the nodes, the mentioned ones are ignored.
      See code below. When run, only the second node is printed. Changing the first "false" to "true" causes the first node to be printed as well.
      Is it a bug, or do we miss something in the format?
      Thanks

      public void testJXPathIssue() {
      final String result = "{\"abc\":\"12:34\",\"vs\":[" +
      "

      {\"p\": \"12\", \"a\": false}

      ," +
      "

      {\"p\": \"34\", \"a\": true}

      ]}";
      Reader reader = new StringReader(result);
      Object obj = null;
      try {
      obj = JSONValue.parseWithException(reader);
      CompiledExpression exp = JXPathContext.compile("./vs[*]");
      JXPathContext xpathRootContext = JXPathContext.newContext(obj);
      Iterator i = exp.iteratePointers(xpathRootContext);
      while (i.hasNext())

      { Pointer item = (Pointer) i.next(); System.out.println("Item = " + item); }

      } catch (IOException e)

      { e.printStackTrace(); } catch (ParseException e) { e.printStackTrace(); }

      }

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              gorenil Yoram
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated: