Skip to main content

$hash

$hash(value?) -> number
Compact type signature<j-:n>

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

Source: FUME

Documentation

Returns a deterministic 32-bit unsigned integer hash for any JSON value.

Strings are hashed as-is. Numbers, booleans, and null are stringified first. Arrays and objects are stably stringified with sorted keys before hashing, so logically equivalent objects produce the same hash even when their key order differs. Undefined input returns undefined.

Examples

Hash equivalent identifier objects consistently

Input

This example uses the patient-summary example input. The expression hashes the same identifier data twice with different key orderings and confirms that the hash stays stable.

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

$hash(identifiers) = $hash({"recordNumber": identifiers.recordNumber, "memberId": identifiers.memberId})

Result

true