...
Code Block |
---|
| {
"messages": {
"staging": [
{
"author" : "tim_bot",
"category": "information",
"message" : "Building..."
},
{
"author" : "tim_bot",
"category": "information",
"message" : "Testing..."
},
{
"author" : "tim_bot",
"category": "information",
"message" : "Completed!"
}
],
"production": [
{
"author" : "jill_bot",
"category": "information",
"message" : "Building..."
},
{
"author" : "jill_bot",
"category": "error",
"message" : "Build Failed!"
}
]
}
} |
| Code Block |
---|
| <?xml version="1.0" encoding="UTF-8" ?>
<messages>
<staging>
<category>information</category>
<message>Building...</message>
</staging>
<staging>
<category>information</category>
<message>Testing...</message>
</staging>
<staging>
<category>information</category>
<message>Completed!</message>
</staging>
<production>
<category>information</category>
<message>Building...</message>
</production>
<production>
<category>error</category>
<message>Build Failed!</message>
</production>
</messages> |
|
---|
The following are example XPath and JSONPaths that could be used on the above responses to extract information your looking for.
XPath | JSONPath | Result |
/storemessages/bookstaging/author | $.store.book[*].author | the authors of all books in the store |
//author | $..author | all authors |
/store/* | $.store.* | all things in store, which are some books and a red bicycle. |
/store//price | $.store..price | the price of everything in the store. |
//book[3] | $..book[2] | the third book |
//book[last()] | $..book[(@.length-1)]
$..book[-1:] | the last book in order. |
//book[position()<3] | $..book[0,1]
$..book[:2] | the first two books |
//book[isbn] | $..book[?(@.isbn)] | filter all books with isbn number |
//book[price<10] | $..book[?(@.price<10)] | filter all books cheapier than 10 |
//* | $..* | all Elements in XML document. All members of JSON structure. |
...