Skip to main content

jsonc2json ~ convert jsonc 2 json ~ python + rust

Project description

jsonc2json

python & rust package to strip comments from jsonc strings/bytes

uses: https://docs.rs/json_comments/latest/json_comments/

Install:

pip install jsonc2json

Usage:

from jsonc2json import jsonc2json

jsonc_string = """
{
    "name": /* full */ "John Doe",
    "age": 43,
    "phones": [
        "+44 1234567", // work phone
        "+44 2345678"  // home phone
    ]  # hash comment
}
""".strip()

json_string = jsonc2json(jsonc_string)

print(json_string)
# PRINTS:
# {
#     "name":            "John Doe",
#     "age": 43,
#     "phones": [
#         "+44 1234567",
#         "+44 2345678"
#     ]
# }

assert isinstance(json_string, str)
assert isinstance(jsonc2json(jsonc_string.encode()), bytes)

CLI

# stdin
$ echo '{"a": 1 /* comment */, "b": 2}' | python -m jsonc2json
'{"a": 1              , "b": 2}'
# file (still stdin!)
$ python -m jsonc2json < has-comments.jsonc > no-comments.json

TODO:

  • Add options present in the rust package
  • Clap CLI?
  • build confit

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

jsonc2json-0.0.4.tar.gz (5.6 kB view hashes)

Uploaded Source

Built Distributions

jsonc2json-0.0.4-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (986.7 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

jsonc2json-0.0.4-pp310-pypy310_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (991.9 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARMv7l

jsonc2json-0.0.4-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (973.7 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

jsonc2json-0.0.4-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl (1.0 MB view hashes)

Uploaded PyPy manylinux: glibc 2.5+ i686

jsonc2json-0.0.4-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (986.8 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

jsonc2json-0.0.4-pp39-pypy39_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (991.9 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARMv7l

jsonc2json-0.0.4-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (973.7 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

jsonc2json-0.0.4-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl (1.0 MB view hashes)

Uploaded PyPy manylinux: glibc 2.5+ i686

jsonc2json-0.0.4-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (986.7 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

jsonc2json-0.0.4-pp38-pypy38_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (991.8 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARMv7l

jsonc2json-0.0.4-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (973.7 kB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

jsonc2json-0.0.4-pp38-pypy38_pp73-manylinux_2_5_i686.manylinux1_i686.whl (1.0 MB view hashes)

Uploaded PyPy manylinux: glibc 2.5+ i686

jsonc2json-0.0.4-cp312-none-win_amd64.whl (107.4 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

jsonc2json-0.0.4-cp312-none-win32.whl (106.3 kB view hashes)

Uploaded CPython 3.12 Windows x86

jsonc2json-0.0.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (986.1 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

jsonc2json-0.0.4-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (991.0 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARMv7l

jsonc2json-0.0.4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (973.3 kB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

jsonc2json-0.0.4-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl (1.0 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.5+ i686

jsonc2json-0.0.4-cp312-cp312-macosx_11_0_arm64.whl (216.8 kB view hashes)

Uploaded CPython 3.12 macOS 11.0+ ARM64

jsonc2json-0.0.4-cp312-cp312-macosx_10_12_x86_64.whl (218.0 kB view hashes)

Uploaded CPython 3.12 macOS 10.12+ x86-64

jsonc2json-0.0.4-cp311-none-win_amd64.whl (107.3 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

jsonc2json-0.0.4-cp311-none-win32.whl (106.2 kB view hashes)

Uploaded CPython 3.11 Windows x86

jsonc2json-0.0.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (986.6 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

jsonc2json-0.0.4-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (991.1 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARMv7l

jsonc2json-0.0.4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (973.1 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

jsonc2json-0.0.4-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl (1.0 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.5+ i686

jsonc2json-0.0.4-cp311-cp311-macosx_11_0_arm64.whl (217.3 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

jsonc2json-0.0.4-cp311-cp311-macosx_10_12_x86_64.whl (218.2 kB view hashes)

Uploaded CPython 3.11 macOS 10.12+ x86-64

jsonc2json-0.0.4-cp310-none-win_amd64.whl (107.4 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

jsonc2json-0.0.4-cp310-none-win32.whl (106.3 kB view hashes)

Uploaded CPython 3.10 Windows x86

jsonc2json-0.0.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (986.7 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

jsonc2json-0.0.4-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (991.4 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARMv7l

jsonc2json-0.0.4-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (973.3 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

jsonc2json-0.0.4-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl (1.0 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.5+ i686

jsonc2json-0.0.4-cp310-cp310-macosx_11_0_arm64.whl (217.5 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

jsonc2json-0.0.4-cp310-cp310-macosx_10_12_x86_64.whl (218.3 kB view hashes)

Uploaded CPython 3.10 macOS 10.12+ x86-64

jsonc2json-0.0.4-cp39-none-win_amd64.whl (107.2 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

jsonc2json-0.0.4-cp39-none-win32.whl (106.4 kB view hashes)

Uploaded CPython 3.9 Windows x86

jsonc2json-0.0.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (986.6 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

jsonc2json-0.0.4-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (991.4 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARMv7l

jsonc2json-0.0.4-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (973.7 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

jsonc2json-0.0.4-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl (1.0 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.5+ i686

jsonc2json-0.0.4-cp38-none-win_amd64.whl (107.2 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

jsonc2json-0.0.4-cp38-none-win32.whl (106.2 kB view hashes)

Uploaded CPython 3.8 Windows x86

jsonc2json-0.0.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (986.1 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

jsonc2json-0.0.4-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (990.9 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARMv7l

jsonc2json-0.0.4-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (973.2 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

jsonc2json-0.0.4-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl (1.0 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.5+ i686

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page