An extension for JSON to support file inclusion
json-include is an extended way for JSON to support file inclusion, it has two parts:
A syntax definition called include syntax.
A Python implementation to parse and build JSON file that contains include syntax.
Syntax
json-include supports an extended syntax called include syntax in JSON, formatted as:
{
"...": "<json file name>"
}
The include syntax means that this object (the whole {"...": "<json file name>"}) in JSON is a reference to the JSON file named in <json file name> notation, and should be included into its place.
The included JSON should always be an object (dict) rather than an array (list), to prevent implicit meaning and make sure we can get a clear view of the structure without looking into the included JSON files.
In a normal JSON when we want to include another JSON on an attribute, it should be written as follows:
{
"username": "alice",
"profile": {
"...": "<profile_model.json>"
}
}
In this JSON a profile_model.json is included to present profile attribute, if the content of profile_model.json is like:
{
"age": 18,
"gender": "female"
}
then what we mean by the include syntax is that, when this JSON is being used as a normal JSON, it should be seen as:
{
"username": "alice",
"profile": {
"age": 18,
"gender": "female"
}
}
To ture JSON with include syntax into a normal JSON, a build process is needed, that’s what the implementation does.
Python Implementation
Implementation could be of any language as long as it can understand the include syntax and output as expected, this repo contains a Python implementation for use.
Installation
pip install json-include
Usage
By installation a command called json-include will be registerd as an entry point, use it as follows:
usage: json-include [-h] DIR FILE Command line tool to build JSON file by include syntax. positional arguments: DIR The directory path of source json files FILE The name of the source json file optional arguments: -h, --help show this help message and exit
For example:
json-include test/source_json/ c.json
The parsed and built result of c.json will be printed.
Further usage of json_include package is documented in its source code, and test/ can also give you better understandings of how it works.
TODOs
[ ] Prevent circluar inclusion
[ ] Test circluar inclusion
[ ] Test invalid syntax
Metadata
Release files for json-include 0.1.4
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 |
|---|---|---|---|---|
| json-include-0.1.4.tar.gz | 3.8 kB | Without provenance | Details for json-include-0.1.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| json_include-0.1.4-py2-none-any.whl | Python 2 | none | any | Details for json_include-0.1.4-py2-none-any.whl |
Total release size: 9.8 kB
Release files / json-include-0.1.4.tar.gz
| Download URL | json-include-0.1.4.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e1c3879f8d27d4dd25003dd4fea392f640ad21be1f837ef8a243842e36588632
|
|
BLAKE2b-256 checksum How to use checksums |
8a29d92c9d1974023986b7369829acf734c953c9e8a284ec533450c58dcbf3aa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / json_include-0.1.4-py2-none-any.whl
| Download URL | json_include-0.1.4-py2-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
8c0eb7aa1aabde2807a08ee2cccfe8c11d90e9fab44e1a12c83c920291468876
|
|
BLAKE2b-256 checksum How to use checksums |
c8b0a0108d3babb701cdf60a29d9c3114514c5ffe9a56820ee91b18d076c62eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for json-include 0.1.4
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.