FileLoader JSON
Stdlib-backed JSON file loader for the vcti-fileloader framework
Overview
vcti-fileloader-json is a JSON loader plugin for the vcti-fileloader
framework. It implements the Loader protocol: populate(handle, tree, parent) parses a JSON file with the Python standard library json
module and attaches the parsed value (a dict, list, scalar, or
None) as the .data of a single child under a one-node subtree.
The returned subtree is structure-locked and payload-locked.
The package depends only on vcti-fileloader and vcti-tree; the
JSON parser is the Python stdlib. JSON files have no native attribute
mechanism, so the loader stamps no file_attributes — callers that
want to enrich with file paths, tags, or derived metadata should use
the before_lock hook on populate.
Installation
pip install "vcti-fileloader-json>=2.0.0"
In pyproject.toml dependencies
dependencies = [
"vcti-fileloader-json>=2.0.0",
]
Quick Start
import json
from pathlib import Path
from vcti.fileloader.core import DataNode, prepare_loader
from vcti.fileloader.json import JsonLoader
from vcti.tree.core import DictTree
# A small file to load.
path = Path("config.json")
path.write_text(json.dumps({"name": "demo", "values": [1, 2, 3]}), encoding="utf-8")
loader = JsonLoader()
prepare_loader(loader) # once, before first use; raises ValidationError / SetupError
tree: DictTree[DataNode] = DictTree(DataNode())
with loader.open(path) as handle:
subtree_root = loader.populate(handle, tree, tree.root_handle)
# The parsed value is the `.data` of the subtree root's single child.
[child_handle] = tree.children(subtree_root)
parsed = tree.payload(child_handle).data
print(parsed) # {'name': 'demo', 'values': [1, 2, 3]}
The subtree has the same two-node shape whatever the file's top-level value is: an empty root, and one child carrying the parsed value.
With a before_lock hook
JSON has no native attribute mechanism, so all attribute stamping happens via the hook. A typical pattern is to attach the file path:
def stamp_file_path(tree, root):
tree.payload(root).enricher_attributes["file_path"] = str(path)
with loader.open(path) as handle:
root = loader.populate(handle, tree, tree.root_handle, before_lock=stamp_file_path)
print(tree.payload(root).attributes["file_path"]) # config.json
Key API
JsonLoader
| Method | Description |
|---|---|
load(path, **options) |
Parse the JSON file and return the parsed value. encoding option, default utf-8-sig |
open(path, **options) |
Context manager — load and auto-unload |
populate(handle, tree, parent, *, before_lock=None, **options) |
Attach the parsed value as a single locked subtree |
unload(handle) |
No-op (the parsed value is in memory; nothing to release) |
can_load(path) |
Check extension (.json) |
Helpers
| Description | |
|---|---|
get_loader_descriptor() |
Create a LoaderDescriptor for a LoaderRegistry |
JsonValidator |
Verify the stdlib json module is importable |
JsonSetup |
No-op setup |
Error Handling
from vcti.fileloader.core import (
LoadError,
TreeAttachmentError,
UnsupportedFormatError,
)
try:
with loader.open(path) as handle:
subtree_root = loader.populate(handle, tree, tree.root_handle)
except FileNotFoundError:
...
except UnsupportedFormatError:
# File extension is not .json
...
except LoadError:
# File could not be opened or decoded, or contained invalid JSON
# (NaN / Infinity count as invalid)
...
except TreeAttachmentError:
# parent is missing, deleted, or structure-locked in `tree`
...
If populate fails partway (for example, a before_lock exception),
the partial subtree is removed before the exception propagates —
callers never see a half-built subtree.
Dependencies
- vcti-fileloader (>=7.0.0, <8) —
Loaderprotocol,SubtreeBuilder,DataNode(import fromvcti.fileloader.core) - vcti-tree (>=3.0.0, <4) —
LockableTreeprotocol
The JSON parser is json from the Python standard library — no
third-party dependency.
Documentation
| If you want to… | Read |
|---|---|
| Get started using the package | Quick Start above |
| Understand the subtree shape, the attribute model, the encoding default, and what the loader leaves out | docs/design.md |
Metadata
Release files for vcti-fileloader-json 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| vcti_fileloader_json-2.0.0.tar.gz | 18.1 kB | With provenance | Details for vcti_fileloader_json-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| vcti_fileloader_json-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for vcti_fileloader_json-2.0.0-py3-none-any.whl |
Total release size: 26.0 kB
Release files / vcti_fileloader_json-2.0.0.tar.gz
| Download URL | vcti_fileloader_json-2.0.0.tar.gz |
|---|---|
| Size | 18.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f4ae21f4d818dc29ceb487d449705125febd94e310557892b403202ea48634bd
|
|
BLAKE2b-256 checksum How to use checksums |
9e3cf32b0d83552c7a3eb3a963265912cecf60d76148492e5688835de90c3b10
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logRelease files / vcti_fileloader_json-2.0.0-py3-none-any.whl
| Download URL | vcti_fileloader_json-2.0.0-py3-none-any.whl |
|---|---|
| Size | 7.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
472da8b059c2a14c67c4ebb8a2ac0d90310708db405409aca88d58b3faa287b8
|
|
BLAKE2b-256 checksum How to use checksums |
ac7ef90a0e467b2286aed679392d2b1abc16a8ac8824b0731858345cd2411ead
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logSecurity for vcti-fileloader-json 2.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for vcti_fileloader_json-2.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.