Given a JSON object like:
"book": [
{
"category": "reference",
"author": "Nigel Rees",
"book_id": "214515",
"title": "Sayings of the Century",
"price": 8.95,
"reviews": [
{
"rating": 2,
"reviewer": "Amazon",
"weight": 0
},
{
...
}
]
},
{
...
}
Is it at all possible to select book_id, along with part or all of the reviews for that book?
The result might look something like this:
[
{
"book_id": "...",
"reviews": [
...
]
},
{
...
}
]
I've been using Jayway jsonpath: https://github.com/json-path/JsonPath
The following is not suitable a solution when dealing with arrays, like the 'reviews', and then joining programmatically:
List ids = JsonPath.read(json, "$.store.books[*].book_id");
List reviews = JsonPath.read(json, "$.store.books[*].reviews[*]");