capturegraph.procedures.exporting.serializer
#
Procedure Serialization#
This module handles the serialization of procedure graphs to JSON format for execution by the app. The serializer converts the Python procedure DAG into a structured JSON representation that the mobile app can parse and execute.
procedure_to_dict(procedure)
#
Serializes a Procedure DAG into a dictionary representation.
The procedure graph is flattened into nodes with unique IDs, capturing their kinds, return types, labels, settings, inputs, and substeps. The resulting dictionary can be easily converted to JSON for transmission to the app.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
procedure
|
Procedure[PVoid]
|
The root Procedure node to serialize |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary representing the serialized procedure graph |
Source code in capturegraph-lib/capturegraph/procedures/exporting/serializer.py
procedure_to_json(procedure, indent=4, **json_kwargs)
#
Serializes a Procedure DAG into a JSON string representation.
This function converts the procedure graph into a structured JSON format that can be transmitted to the app for execution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
procedure
|
Procedure[PVoid]
|
The root Procedure node to serialize |
required |
indent
|
int
|
Number of spaces for JSON indentation (default: 4) |
4
|
**json_kwargs
|
Any
|
Additional keyword arguments for json.dumps |
{}
|
Returns:
| Type | Description |
|---|---|
str
|
A JSON string representing the serialized procedure graph |