plaid.utils.cgns_json¶
plaid.utils.cgns_json
¶
JSON serialization helpers for CGNS trees.
The helpers in this module serialize a single pyCGNS-style tree node of the
form [name, value, children, label] to a language-neutral JSON payload.
Node values are encoded with :mod:plaid.utils.json_codec, which stores NumPy
arrays as base64 little-endian C-contiguous bytes with explicit dtype and shape
metadata so the payload can be decoded from Python, MATLAB, R, JavaScript, or
any language with base64 and typed-array support.
plaid.utils.cgns_json.cgns_tree_to_json_payload
¶
Convert a CGNS tree to a JSON-compatible payload.
Parameters:
-
tree(list[Any]) –pyCGNS-style node
[name, value, children, label].
Returns:
-
dict[str, Any]–A JSON-compatible dictionary containing format metadata and the encoded
-
dict[str, Any]–tree.
Source code in plaid/utils/cgns_json.py
plaid.utils.cgns_json.cgns_tree_from_json_payload
¶
Rebuild a CGNS tree from a JSON-compatible payload.
Parameters:
-
payload(dict[str, Any]) –Payload produced by :func:
cgns_tree_to_json_payload.
Returns:
-
list[Any]–A pyCGNS-style node
[name, value, children, label].
Raises:
-
ValueError–If the payload format or version is unsupported.
Source code in plaid/utils/cgns_json.py
plaid.utils.cgns_json.cgns_tree_to_json
¶
Convert a CGNS tree to a JSON string.
Parameters:
-
tree(list[Any]) –pyCGNS-style node
[name, value, children, label]. -
**json_kwargs(Any, default:{}) –Extra keyword arguments forwarded to :func:
json.dumps.
Returns:
-
str–A JSON string containing the encoded CGNS tree.
Source code in plaid/utils/cgns_json.py
plaid.utils.cgns_json.cgns_tree_from_json
¶
Rebuild a CGNS tree from a JSON string.
Parameters:
-
text(str) –JSON string produced by :func:
cgns_tree_to_json.
Returns:
-
list[Any]–A pyCGNS-style node
[name, value, children, label].