This is a Rest API for querying and pretty-printing JSON objects. Handy for Bash JSON parsing.
1.5K
This is a simple API for querying and pretty-printing JSON objects via a REST API.
Once set, build the Docker image manually or via the included Fig file.
$ docker build --rm=true -t agaveapi/json-mirror .
$ docker run -d --name json-mirror \
-p 3000:3000 \
agaveapi/json-mirror
The API will be available at http://<docker host>:3000.
The API works like pretty much every other prettyprinting service works. You send a POST request to the API and it mirrors the JSON back to you.
curl -H "Content-Type: application/json" -X POST --data-binary '{"message": "Hello world"}' 'http://<docker host>.com:3000'
You can also use JavaScript dot notation to return a portion of the POSTed JSON object. This is handy when you don't have a viable JSON parser available (BASH, I'm talking to you!).
curl -X POST -H "Content-Type: application/json" \
--data-binary '{"foo": "manchu", "bar": "bara"}' \
'http://<docker host>:3000/?q=foo'
"manchu"
curl -X POST -H "Content-Type: application/json" \
--data-binary '{"foo": "manchu", "bar": "bara", "baz": ["one foo", "two foo", "red foo", "blue food"], "zap": { "boom": "here comes the"} }' \
'http://<docker host>:3000/?q=baz.[1]'
"two foo"
curl -X POST -H "Content-Type: application/json" \
--data-binary '[{"key":"foo","value":"manchu"},{"key":"bar":"value":"bara"},{"key":"baz","value":"zarre"}]' \
'http://<docker host>:3000/?q=baz.[].key'
docker pull agaveapi/json-mirror:latest