Skip to main content

JSON exporter plugin for vcti-tree-exporter: writes a vcti tree to a single .json document (nested nodes carrying name, attributes, and light arrays as JSON lists).

Project description

JSON Tree Exporter

JSON exporter plugin for vcti-tree-exporter: writes a vcti tree to a single .json document.

JsonExporter serializes any vcti-tree tree whose node payloads are vcti-datanode DataNodes to one JSON document that mirrors the tree, and ships a get_exporter_descriptor() factory so a consumer registers it in a catalog and resolves it by id ("json") or by attribute lookup.

JSON is a natural fit for structure, metadata, and light arrays — simulation settings, CAE metadata, input decks — that load straight into tooling. It is a poor fit for large numeric arrays (they become bulky nested lists); use HDF5 or NPZ for heavy data.

Installation

pip install vcti-tree-exporter-json

This pulls in vcti-tree-exporter (the protocol/catalog) and numpy.

Tree → JSON mapping

Each node becomes an object; the document root is the tree's root node:

{
  "name": "model",
  "attributes": {"solver": "abaqus"},
  "children": [
    {"name": "info", "attributes": {"count": 7}},
    {"name": "displacement", "attributes": {}, "data": [1.0, 2.0, 3.0]}
  ]
}
Tree node part JSON
node.name "name" (the structural name; null if unset)
node.attributes "attributes" object (always present)
node.load() array "data" as nested lists (present only for data nodes)
children "children" array (present only when non-empty)

A node may carry both data and children. Attribute values are JSON-encoded (bytes decoded, numpy scalars/arrays converted to numbers/lists); anything not natively serializable falls back to its str(). Array dtype is not preserved — the export is one-way.

Usage

from pathlib import Path
from vcti.tree.exporter.core import build_registry, get_exporter
from vcti.tree.exporter.json import get_exporter_descriptor

registry = build_registry([get_exporter_descriptor()])   # plus any other format plugins
get_exporter(registry, "json").export(tree, Path("model.json"), overwrite=True)

Or use the exporter directly:

from vcti.tree.exporter.json import JsonExporter
JsonExporter().export(tree, Path("model.json"))

Dependencies

  • vcti-tree-exporter — the Exporter protocol and the ExporterDescriptor catalog.
  • vcti-tree / vcti-datanode — the tree and payload types.
  • numpy. (JSON encoding itself uses only the standard library.)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vcti_tree_exporter_json-2.0.0.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vcti_tree_exporter_json-2.0.0-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file vcti_tree_exporter_json-2.0.0.tar.gz.

File metadata

  • Download URL: vcti_tree_exporter_json-2.0.0.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for vcti_tree_exporter_json-2.0.0.tar.gz
Algorithm Hash digest
SHA256 60b06e8e4c626424c0f122675623b9fb0e2e4fbb74fadb62168bb741835c4893
MD5 15d6de87a6f3496923fd70d6f67c2cf4
BLAKE2b-256 cff72c71bf2d206d4d48b90681862d3b8ef376df58060b41be5988b8b77133a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for vcti_tree_exporter_json-2.0.0.tar.gz:

Publisher: release.yml on vcollab/vcti-python-tree-exporter-json

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file vcti_tree_exporter_json-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for vcti_tree_exporter_json-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4090952cbafb30194e8c31407d4be96a236681c68794ffb8e81cee7814923bd0
MD5 de66868b31339f1d6546d2c683077c5b
BLAKE2b-256 02608e99ffb4fc5bf8093eff9db2bab522dd5bf26c9a79cc82c0d7e3a829355d

See more details on using hashes here.

Provenance

The following attestation bundles were made for vcti_tree_exporter_json-2.0.0-py3-none-any.whl:

Publisher: release.yml on vcollab/vcti-python-tree-exporter-json

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page