2.1.0 • Published 4 years ago

json-pretty-parse-cli v2.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

json-pretty-parse-cli Build Status

Command line interface to unescape and format JSON data using stringify and parse

When I need to check a JSON message from a log entry, I often get an escaped string with no spaces, no new lines. Then the journey begin, I open a text-editor, replace all escaped quotes, open a new tab with a JSON formatted, copy/paste the unescaped JSON, format, copy/paste the result back to my text-editor, I'm good to go.

With jsonpp, first I use JSON.stringify and for each string entries with escaped strings, I do a JSON.parse using the replacer function. This may not be the fastest way to do it, but it seems solid so far.

If you need a command to unescape and format a JSON string, jsonpp is your man or woman.

Install

$ npm install --global json-pretty-parse-cli

If you don't want to install the package globally, you can use npx instead

$ npx @haroun/json-pretty-parse-cli

Usage

$ jsonpp --help

  Usage
    $ jsonpp [--space] <string>
    $ echo <string> | jsonpp [--space]

  Options
    -s, --space Space

  Examples
    $ jsonpp '{"number":42,"string":"string"}'
    {
      "number": 42,
      "string": "string"
    }

    $ jsonpp -s 4 '{\"number\":42,\"string\":\"string\"}'
    {
        "number": 42,
        "string": "string"
    }

    $ echo '{\\\"number\\":42,\\\"string\\\":\\\"string\\\"}' | jsonpp
    {
      "number": 42,
      "string": "string"
    }

    $ echo '{"number":42,"string":"string"}' | jsonpp -s 4
    {
        "number": 42,
        "string": "string"
    }

License

MIT © Harouna Traore

2.1.0

4 years ago

2.0.0

5 years ago

1.0.1

6 years ago

1.0.0

7 years ago