Skip to main content

pointer_to_fhirpath

Function pointer_to_fhirpath 

Source
pub fn pointer_to_fhirpath(pointer: &str) -> String
Expand description

Renders an RFC 6901 JSON pointer as a dotted FHIRPath-style expression rooted at ViewDefinition, e.g. /select/0/column/1/path becomes ViewDefinition.select[0].column[1].path, and the document root ("") becomes plain ViewDefinition.

This is the shape $sql-run’s 422 response puts in OperationOutcome.issue.expression (crate::error::ServerError) so a client can jump straight to the offending node without knowing JSON Pointer syntax — and it’s pub so the /ui/sql/view-definitions/lint handler can reuse it for the same purpose in the editor.

Each /-separated pointer segment either names an array index (all ASCII digits — a ViewDefinition document never has an object key that is itself numeric, so this can’t misfire) and becomes a [N] suffix on the segment before it, or names an object key and becomes a .key suffix, after undoing RFC 6901’s own escaping (~1/, then ~0~, in that order — reversing the encoding, which escapes ~ before /).