am_get: Get a value from an Automerge map or list

View source: R/objects.R

am_getR Documentation

Get a value from an Automerge map or list

Description

Retrieves a value from an Automerge map or list. Returns NULL if the key or index doesn't exist.

Usage

am_get(doc, obj, key)

Arguments

doc

An Automerge document

obj

An Automerge object ID (from nested object), or AM_ROOT for the document root

key

For maps: character string key. For lists: numeric index (1-based). Returns NULL for indices ⁠<= 0⁠ or beyond list length.

Value

The value at the specified key/position, or NULL if not found. Nested objects are returned as am_object instances.

Examples

doc <- am_create()
am_put(doc, AM_ROOT, "name", "Alice")

name <- am_get(doc, AM_ROOT, "name")
name  # "Alice"

am_close(doc)


automerge documentation built on Feb. 5, 2026, 5:08 p.m.