Skip to main content

Coverage Status Pearmaster

jacobs-json-doc

A JSON/YAML loader for Python3.

PyYAML or ruamel.yaml do a good job at parsing YAML or JSON into a Python object. This package wraps ruamel.yaml to provide a little bit of extra functionality.

Line Numbers

If you're trying to do use parts of a JSON/YAML document, and you find that the structure of the document didn't conform to a schema or expectations, then you might want to display an error saying something like "On line 123, the value of foo was missing." This package allows easier access to the YAML/JSON line numbers by accessing the .line property.

Dollar References

JSON Schema, OpenAPI, AsyncAPI, and others have a concept of references like this: {"$ref": "other.json#/path/to/definition"}.

The idea here is that instead of the JSON object with the $ref you should be able to get a JSON structure from somewhere else. In this example, you should find a document called other.json and pull out a structure at /path/to/definition.

Fetcher

A fetcher object (inherits from jacobsjsondoc.fetcher.FetcherBaseClass) is able to get the JSON/YAML source. The fetcher can be different if you are loading from a database, filesystem, http, etc.

Reference Modes

Given a fetcher, jacobs-json-doc can deal with dollar references. There are two modes for how it can deal with references:

  • Use DocReference objects. Anywhere in the document tree where there is a $ref reference, a DocReference object is created.
  • Automatic resolution. Anywhere in the document tree where there is a $ref reference, the reference is automatically resolved and the $refs are replaced with the structures that they were referencing.

Examples

The test_document.py file is a good source for examples.

A very brief example is:

from jacobsjsondoc.document import create_document

my_document = "/path/to/example.yaml"
doc = create_document(uri=my_document)
print(doc['a']['b'])
print(doc['a']['b'].line)

If you are loading a single bit of data, without any $ref references, you can do it like this:

import jacobsjsondoc
text_data = '{"hello":"world"}'
doc = jacobsjsondoc.parse(text_data)

License

MIT

Metadata

Release files for jacobs-json-doc 0.18.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jacobs-json-doc 0.18.0
File Size Uploaded Provenance Actions
jacobs_json_doc-0.18.0.tar.gz 51.2 kB Without provenance Details for jacobs_json_doc-0.18.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for jacobs-json-doc 0.18.0
File Interpreter ABI Platform Actions
jacobs_json_doc-0.18.0-py3-none-any.whl Python 3 none any Details for jacobs_json_doc-0.18.0-py3-none-any.whl

Total release size: 70.9 kB

Release files / jacobs_json_doc-0.18.0.tar.gz

Download URL jacobs_json_doc-0.18.0.tar.gz
Size 51.2 kB
Tags Source
SHA-256 checksum
How to use checksums
fc69e0efed9b07d3ca565bc822ee5cb354dee8c0de439397d18e9312bf53cb47
BLAKE2b-256 checksum
How to use checksums
725d1ff8326e423b2fab86e5bfd3307267e2cfe091eaf0a95cb37f73f1709eaf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / jacobs_json_doc-0.18.0-py3-none-any.whl

Download URL jacobs_json_doc-0.18.0-py3-none-any.whl
Size 19.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a9e6289ea39a1b320cebe88d4efb53293253327bae7bf06d0893f3f17e123530
BLAKE2b-256 checksum
How to use checksums
4bbf41ad2d399bf3b8ed1925993d9ac695adba1ba3d1a5d6c082bf189dcd8ca2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for jacobs-json-doc 0.18.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A 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.

Release history Release notifications | RSS feed

This release

0.18.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page