Skip to main content

Module path

Module path 

Source
Expand description

Dotted-path JSON operations.

Four pure functions over serde_json::Value:

  • path_get — read the value at a dotted path, None if missing
  • path_set — write a value at a dotted path, auto-vivifying objects and growing arrays with null padding
  • path_has — test for presence
  • [path_delete — remove a key/index; returns true if something was removed

Numeric segments are interpreted as array indices when the current node is an array; otherwise they’re treated as object keys (so map.0.name is a valid path into {"0": {"name": …}}).

Used by __hypen_bind (renderer → state) and by every host SDK’s ObservableState implementation. Centralising here removes four hand-ports of the same auto-vivification semantics.

Functions§

path_delete
Remove whatever lives at path. Returns true if a key/index was actually removed, false if the path didn’t resolve. Array indices are removed by splicing (the array shrinks by one). Empty path is a no-op that returns false.
path_get
Read the value at a dotted path. Returns None if any segment fails to resolve.
path_has
Test whether a dotted path resolves to a value.
path_set
Write new_value at path inside target. Intermediate objects are created as needed; arrays are extended with Value::Null up to the target index. Numeric segments map to array indices only when the current node is already an array.