Skip to main content

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_start is the start of the value,
    • value_end is the end of the value,
    • key_start is the start of the key (which is None at the root level and for array items),
    • key_end is the end of the key (which is None at the root level and for array items) and
  • each of the above have the following properties:
    • line is the zero-indexed line position,
    • column is the zero-indexed column position and
    • position is 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, booleans and null),
  • support for structural types (array and object) and
  • support for space, tab, carriage and return whitespace.

Metadata

Release files for json-source-map 1.0.5

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

Source distribution (sdist)

Source distribution for json-source-map 1.0.5
File Size Uploaded
json_source_map-1.0.5.tar.gz 6.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for json-source-map 1.0.5
File Interpreter ABI Platform
json_source_map-1.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 14.1 kB

Release files / json_source_map-1.0.5.tar.gz

Download URL json_source_map-1.0.5.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
de99103c0637707368eb888d7aaa82bad1e21dbe2d21813998caabaa7c2e52f9
BLAKE2b-256 checksum
How to use checksums
e6f0560df0f36ad3e6c1e9b2a077a297df2c4dc4a2c427580d1995782aff67d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.16

Release files / json_source_map-1.0.5-py3-none-any.whl

Download URL json_source_map-1.0.5-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c8ddb8db76dc238fce485abb548e5c7fc2b44d5ae8efb766e90e7c15840afaca
BLAKE2b-256 checksum
How to use checksums
2f5cbdddb48cf521428117bd1338c531c0027f1c32beba23c89f9713229fe17c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.16

Release history Release notifications | RSS feed

This release

1.0.5 This release

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

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