Calculate the source map for a JSON document.
Project description
JsonSourceMap
Calculate JSON Pointers to each value within a JSON document along with the line, column and character position for the start and end of that value. For more information see: https://github.com/open-alchemy/json-source-map/wiki.
For example:
python -m pip install json_source_map
from json_source_map import calculate
print(calculate('{"foo": "bar"}'))
The above prints:
{
'': Entry(
value_start=Location(line=0, column=0, position=0),
value_end=Location(line=0, column=14, position=14),
key_start=None,
key_end=None,
),
'/foo': Entry(
value_start=Location(line=0, column=8, position=8),
value_end=Location(line=0, column=13, position=13),
key_start=Location(line=0, column=1, position=1),
key_end=Location(line=0, column=6, position=6),
),
}
Where:
- each key in the dictionary is a JSON path to an item,
- each value in the dictionarty contains the mapping of the item at the JSON
path which have the following properties:
value_startis the start of the value,value_endis the end of the value,key_startis the start of the key (which isNoneat the root level and for array items),key_endis the end of the key (which isNoneat the root level and for array items) and
- each of the above have the following properties:
lineis the zero-indexed line position,columnis the zero-indexed column position andpositionis the zero-indexed character position in the string (independent of the line and column).
The following features have been implemented:
- support for primitive types (
strings,numbers,booleansandnull), - support for structural types (
arrayandobject) and - support for space, tab, carriage and return whitespace.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file json_source_map-1.0.5.tar.gz.
File metadata
- Download URL: json_source_map-1.0.5.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de99103c0637707368eb888d7aaa82bad1e21dbe2d21813998caabaa7c2e52f9
|
|
| MD5 |
a7fc7f346e10edfea1c01f92904e5b97
|
|
| BLAKE2b-256 |
e6f0560df0f36ad3e6c1e9b2a077a297df2c4dc4a2c427580d1995782aff67d1
|
File details
Details for the file json_source_map-1.0.5-py3-none-any.whl.
File metadata
- Download URL: json_source_map-1.0.5-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8ddb8db76dc238fce485abb548e5c7fc2b44d5ae8efb766e90e7c15840afaca
|
|
| MD5 |
8aceed45ba1e43dc176f615468bbc248
|
|
| BLAKE2b-256 |
2f5cbdddb48cf521428117bd1338c531c0027f1c32beba23c89f9713229fe17c
|