Skip to main content

$lookup

$lookup(value?, key) -> value
Compact type signature<x-s:x>

If value is omitted, the current context value is used.

Browse categories

Source: JSONata

Documentation

Returns the value associated with key in object. If the first argument is an array of objects, then all of the objects in the array are searched, and the values associated with all occurrences of key are returned.

Examples

Lookup a value by key name

Input

This example uses the patient-summary example input. The expression selects the nested identifiers object and looks up one key by name.

Example input

JSON
{
"patientId": "pat-0001",
"name": {
"given": "Avery",
"family": "Reed",
"display": "Avery Reed"
},
"birthDate": "1990-06-12",
"sex": "female",
"primaryCareTeam": {
"organization": "ExampleCare",
"facility": "ExampleCare Clinic",
"practitioner": {
"practitionerId": "prac-4001",
"display": "Jordan Kim"
}
},
"identifiers": {
"memberId": "mbr-3001",
"recordNumber": "rec-5001"
},
"tags": [
"demo",
"fictional"
],
"_xmlTagName": "patientSummary"
}

Expression

$lookup(identifiers, "memberId")

Result

"mbr-3001"