Skip to main content

$encodeUrl

$encodeUrl(string?) -> string
Compact type signature<s-:s>

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

Source: JSONata

Documentation

Encodes a full URL string using encodeURI() semantics.

Reserved URL separators remain readable, while characters that must be escaped in the overall URL are percent-encoded. Use $encodeUrlComponent() instead when you are encoding a single query value or path fragment. Undefined input returns undefined, and malformed URI input raises a FUME URI error.

Examples

Encode a full patient URL

Input

This example uses the patient-summary example input. The expression builds a URL from the patient ID and display name, then encodes it as a full URL.

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

$encodeUrl("https://example.test/patient/" & patientId & "?display=" & name.display)

Result

"https://example.test/patient/pat-0001?display=Avery%20Reed"