Skip to main content

Edit parts of json strings & files while keeping the orginal, inconsistent formating

Project description

pyJsonEdit

PyPi version license tests

Edit parts of inconsistently formatted json.

It's just a bit slower that doint this by hand!

how to install

pip install --upgrade pyjsonedit

json in python

Pure pyhon implementation of json encoder/decoder.

Its slow and unnecessary!

matcher

Now you can select nodes in json tree

syntax!

  • | select all children in current node -----|----- [n] | select n-th item of curent node {n} | select n-th item of curent node key | select node chilld by name "key"| select node chilld by name > | go to next node

example: mask multiple nodes

$ ./pyjsonedit/print_color "quiz > * > q1 >*" DOC/example.json

{
    "quiz": {
        "sport": {
            "q1": {
                "question": XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX,
                "options": XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX,
                "answer": XXXXXXXXXXXXXXX
            }
        },
        "maths": {
            "q1": {
                "question": XXXXXXXXXXX,
                "options": XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX,
                "answer": XXXX
            },
            "q2": {
                "question": "12 - 8 = ?",
                "options": [
                    "1",
                    "2",
                    "3",
                    "4"
                ],
                "answer": "4"
            }
        }
    }
}

example: mask selected nodes

$ import pyjsonedit
$ pyjsonedit.string_match_mark("{'pass':123}","pass")
{'pass':XXX}

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

pyJsonEdit-0.0.13.tar.gz (5.8 kB view hashes)

Uploaded Source

Built Distribution

pyJsonEdit-0.0.13-py3-none-any.whl (6.8 kB view hashes)

Uploaded Python 3

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