| am_get_path | R Documentation |
Get a value from an Automerge document using a path vector. The path can contain character keys (for maps), numeric indices (for lists, 1-based), or a mix of both.
am_get_path(doc, path)
doc |
An Automerge document |
path |
Character vector, numeric vector, or list of mixed types specifying the path to navigate |
The value at the path, or NULL if not found
doc <- am_create()
am_put(doc, AM_ROOT, "user", list(
name = "Alice",
address = list(city = "NYC", zip = 10001L)
))
# Navigate to nested value
am_get_path(doc, c("user", "address", "city")) # "NYC"
# Mixed navigation (map key, then list index)
doc$users <- list(
list(name = "Bob"),
list(name = "Carol")
)
am_get_path(doc, list("users", 1, "name")) # "Bob"
am_close(doc)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.