0

Way I found to prettify JSON messages from ngrep command:

sudo ngrep -t -W byline port 2012 -d lo | grep "^{" | jq .

TL;DR

We use to check the behavior of our app using ngrep, the messages inside the app uses JSON to share data. However trying to read JSON lines on console where a hard task so we often copy/paste to jsonlint.com to prettify, looking for way to prettify ngrep using stdin we found no guide to how to do it. Above is the way we found.

You need to install jq for this to work.

If you have a better way please add it as an answer.

1 Answers1

1

There is a JSON checker/pretty-printer that comes with Python, it can be used without any Python code like this:

python -m json.tool  [{infile} [{outfile}]]

Where {infile} and {outfile} default to stdin/stdferr.

xenoid
  • 8,888