JSON document store for A2UI surface data.
Provides get/set/delete operations using JSON Pointer (RFC 6901) paths.
Summary
Functions
Deletes a value at the given JSON Pointer path.
Gets a value at the given JSON Pointer path.
Creates a new empty data model.
Creates a data model with initial data.
Sets a value at the given JSON Pointer path.
Types
@type t() :: %A2UI.DataModel{data: map()}
Functions
Deletes a value at the given JSON Pointer path.
Examples
iex> model = A2UI.DataModel.new(%{"a" => 1, "b" => 2})
iex> {:ok, model} = A2UI.DataModel.delete(model, "/a")
iex> model.data
%{"b" => 2}
Gets a value at the given JSON Pointer path.
Returns {:ok, value} if found, :error if the path doesn't exist.
Examples
iex> model = A2UI.DataModel.new(%{"user" => %{"name" => "Alice"}})
iex> A2UI.DataModel.get(model, "/user/name")
{:ok, "Alice"}
iex> model = A2UI.DataModel.new(%{"a" => 1})
iex> A2UI.DataModel.get(model, "/")
{:ok, %{"a" => 1}}
@spec new() :: t()
Creates a new empty data model.
Creates a data model with initial data.
Sets a value at the given JSON Pointer path.
Auto-vivifies intermediate maps as needed.
Examples
iex> model = A2UI.DataModel.new()
iex> {:ok, model} = A2UI.DataModel.set(model, "/user/name", "Alice")
iex> A2UI.DataModel.get(model, "/user/name")
{:ok, "Alice"}