The simplest way is to use NodeJS. It takes a little code, but it's pretty simple. The code is listed below.
#!/usr/bin/env node process.stdin.setEncoding('utf8'); var s = ''; process.stdin.on('readable', function() { var chunk = process.stdin.read(); if (chunk !== null) { s += chunk; } }); process.stdin.on('end', function() { try { process.stdout.write(JSON.stringify(JSON.parse(s), null, ' ')); } catch(e) { process.stderr.write("Malformed JSON. Aborting.\n"); } });
Here's an example of how to use it:
$ echo '{"array":[1,2,3],"attrib":"value"}' | ppjson { "array": [ 1, 2, 3 ], "attrib": "value" }