Learn R Programming

automerge (version 0.3.0)

am_get: 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)

Value

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

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.

Examples

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

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

am_close(doc)

Run the code above in your browser using DataLab