Question - JSON Path notation filtering for arrays of objects
at88mph opened this issue · 1 comments
at88mph commented
Consider this JSON:
{
"user" : {
"personalDetails" : {
"firstName": "Max",
"lastName": "Power"
},
"identities" : {
"$" : [
{
"identity" : {
"@type" : "HTTP",
"$" : "value1"
}
},
{
"identity" : {
"@type" : "OIDC",
"$" : "value2"
}
}
]
}
If I want to obtain the value if /user/identities/$/identity/$
where the @type
== HTTP
in traditional JSON Path, I could do something like /user/identities/$[?(@.identity.@type=='HTTP')]/identity/$
(not tested, but close). Can something similar be achieved with the data-json-manager
's JSON Pointer syntax? If not, how would I go about this? Thank you.
duboisp commented
Have you try:
<div wb-jsonmanager='{ "url: "yourJSONfile.json#/user/identities/$/", "filter": { "path": "/identity//@type", "value": "HTTP" }, "name": "question1917" }></div>
<p data-json-replace="#[question1917]/identity/$">Will be replaced by the value for the property "$"</p>
Filtering only work on arrays. If you need, it is possible to chain multiple json-manager together.
The JSON pointer functionality work as defined in section 6 of the RFC6901 standard