Hi,
Indeed the .(dot) notation mentioned in Part1 has some limitations. But like
@Jonathan Goldberg mentioned there is also the JSON Path described in Part 6 which provides more capabilities through the JSON Path mechanisms.
However, "characteristics" constructs can become quite complex especially if we have multiple parent arrays and you want to mix & match multiple conditions.
The best way to look at this one is if you can provide a sample payload derived from your scenario where you want to do the filtering.
In certain cases if you want to apply the filtering between two unions of arrays, using JSONPath alone is not enough, you will need to make use of the normalized path expression and apply another filtering on that inside your uS or making use of multiple "filter" constructs and apply the logical AND - however is going to be very important the order of the filtering criteria.
An example where the multiple filters could be like this:
$.result[*].characteristic[?( (@.name=='characteristic1' && @.value=="value1") || (@.name=='characteristic2' && @.value=='value2') )]
The above will return a mix & match between the elements where those characteristics are present. The above results looking at them from the normalized path expressions could be something like this:
[
"$['result'][0]['characteristic'][0]",
"$['result'][0]['characteristic'][1]",
"$['result'][1]['characteristic'][0]"
]
Then, by applying the logic in the uS the only result with both condition is $['result'][0] so that will be the result you're after.
Another solution could be like mentioned above is to make use multiple times of the "filter" selector (taking into account that sometimes the order of them might matter):
filter = $.result[*].characteristic[?(@.name=='characteristic1' && @.value=="value1")] & filter = $.result[*].characteristic[?(@.name=='characteristic2' && @.value=="value2")]
However, this logical and (&) between multiple "filter" selectors is not currently covered by Part 6 but in theory it should work.
Thank you,
Florin
------------------------------
Florin Tene
Vodafone Group
------------------------------
Original Message:
Sent: Oct 11, 2020 09:59
From: Jonathan Goldberg
Subject: TMF 630 - Design principle around filtering
Referring you to @Florin Tene, who wrote the JSON Path section in TMF630, maybe he will be able to advise on how to express the query.
Of course it's not enough to express the semantics, it's also important to implement in the backend in an efficient way.
Hope it helps
------------------------------
Jonathan Goldberg
Amdocs Management Limited
Any opinions and statements made by me on this forum are purely personal, and do not necessarily reflect the position of the TM Forum or my employer.
------------------------------