$selectKeys
$selectKeys(object?, keysToSelect?) -> objectCompact type signature
<o-a<s>?:o>If object is omitted, the current context value is used.
Source: FUME
Documentation
Returns a new object containing only the named keys.
keysToSelect can be a single string or an array of strings, and each selector is compared to object keys using string conversion. If keysToSelect is undefined or null, the function returns an empty object.
Examples
Select only specific keys
Input
This example uses the patient-summary example input. The expression selects only the referenced top-level keys.
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
$selectKeys($, ["patientId", "birthDate"])
Result
{
"patientId": "pat-0001",
"birthDate": "1990-06-12"
}