JSON serialization and deserialization for WolframModel.
Handles all internal types (atoms, tuples, MapSet) that do not have a
native JSON representation.
Vertex encoding
Vertices are encoded as follows inside JSON arrays / objects:
| Elixir type | JSON representation |
|---|---|
integer | JSON number |
atom | ["a", "name"] |
{atom, gen, id} tuple | ["v", "name", gen, id] |
{atom, offset} tuple | ["c", "name", offset] |
The id_generator field (a function) is not serialized. When a model is
loaded it defaults to WolframModel.default_id_gen/0.
Summary
Functions
Deserializes a WolframModel from a JSON file at path.
Serializes a WolframModel to a pretty-printed JSON file at path.
Functions
@spec load(Path.t()) :: {:ok, WolframModel.t()} | {:error, term()}
Deserializes a WolframModel from a JSON file at path.
Returns {:ok, model} on success or {:error, reason} on failure.
@spec save(WolframModel.t(), Path.t()) :: :ok | {:error, term()}
Serializes a WolframModel to a pretty-printed JSON file at path.
Returns :ok on success or {:error, reason} on failure.