I would write it as follows:
let $string := '{ "parties": [ { "id": 0, "role": "CN", "name": "name1" }, { "id": 1, "role": "SH", "name": "name2" } ] }' let $data := json:parse($string) return $data/json/parties[_[name = 'name1'][role = 'CN']]
Martin provided the solution for the XQuery map/array format:
let $data := json:parse($string, map { 'format': 'xquery'}) return $data?parties[exists(?*[?name = 'name1'][?role = 'CN'])]
On Tue, Mar 22, 2022 at 9:48 PM Patrick Durusau patrick@durusau.net wrote:
I'm anticipating incorporation of JSON sources with anonymous nodes and if they all appear with the element name _, how do I distinguish one from another, structurally speaking?
MarkLogic offers some specific workarounds but those are unique (I suspect) to MarkLogic.
The MarkLogic post has an example of the problem I anticipate hitting, especially in biblical studies.
Thanks! Patrick