Decode JSON in Bash with PHP
Join the DZone community and get the full member experience.
Join For FreePut the following in your ~/.bashrc file:
alias json-decode="php -r 'print_r(json_decode(file_get_contents(\"php://stdin\")));'"
Usage from any process:
echo '{"foo":"bar","baz":"qux"}' | json-decode
Or from a cUrl call:
curl -s http://example.com/json/endpoint | json-decode
Published at DZone with permission of Josh Adell, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments