Hello @bentraje,
Thank you for reaching out to us. What you want to do is not possible in the Python API, and at least not trivial in the C++ API.
Background
What you see there when you copy and paste the nodes, is the JSON serialization data format of the maxon API. It works similar to popular abstracted data type serialization systems, as for example the attribute driven XML serialization of C#. I.e., it can serialize almost any data structure and its values, not just nodes. The closest related concept in the classic API would be Resources, although they could only be used to deserialize GUIs and did not store any values (apart from strings), i.e., just stored the structure.
Realized is this with the interface contract DescribeIo, with which data can both be serialized (written from memory to disk) and deserialized (the other way). DescribeIo
is a fairly low-level concept of the maxon C++ API. The more high-level concept is DataDescriptionInterface
. While some parts of this have been wrapped for Python, it has not been done to the extent required here. Added to this is that neither GraphModelInterface
nor GraphNode
are such DataDescriptionInterface
and are instead serialized over NodeTemplateInterface
. So, in the end, you cannot instantiate a GraphNode
directly from a JSON file, even in C++. NodeTemplateInterface
has not been wrapped for Python, but I showed in the Asset API C++ docs how to create and load node assets. The loading part can be done in Python, the creating part not, due to some methods not being wrapped. But this all works over the serialized data stored in asset databases, not the raw JSON, but what a node template effectively stores is such JSON data.
What you can do
Not much, unfortunately, direct node JSON serialization and deserialization is neither supported in the public C++ nor public Python API. You can of course try to start deserializing data yourself with the json
module of Python, but we cannot provide any help with that.
The most realistic thing would be a request for us to support NodeTemplateInterface
in Python, so that you can load and store node setups programatically in a dummy or proper user database.
Cheers,
Ferdinand