commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Laurent Malvert (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (JXPATH-168) Iterator on JSON skips nodes that have a "false" property
Date Mon, 02 Jun 2014 13:20:01 GMT

    [ https://issues.apache.org/jira/browse/JXPATH-168?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14015366#comment-14015366
] 

Laurent Malvert commented on JXPATH-168:
----------------------------------------

I suppose it would be helpful if you could provide a full test case, or at least clarify which
library you use to parse your JSON. I assume JSONValue comes from Jackson, but it could be
any other. Giving the expected output and actual output is also easier than to attempt to
follow explanations.


Note that I don't work on JXPath, I just came across this ticket and I thought it would be
difficult for anyone to really help you without more info, as the JSON string itself is irrelevant
to JXPath: the in-memory object representation will be what it traverses.


> Iterator on JSON skips nodes that have a "false" property
> ---------------------------------------------------------
>
>                 Key: JXPATH-168
>                 URL: https://issues.apache.org/jira/browse/JXPATH-168
>             Project: Commons JXPath
>          Issue Type: Bug
>    Affects Versions: 1.3
>         Environment: Java 1.7
>            Reporter: Yoram
>              Labels: JSON, path, skipped
>
> 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();
>         }
>     }



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message