Use jq to validate and pretty-print json output

jq < file.json
The `jq` tool can also be used do validate json files and pretty print output: ` jq < file.json` Available on several platforms, including newer debian-based systems via `#sudo apt install jq`, mac via `brew install jq`, and from source https://stedolan.github.io/jq/download/ This alternative to the original avoids the useless use of cat
Sample Output
success:
{
  "foo": "bar"
}

error:
$ jq < file.json
parse error: Unmatched '}' at line 1, column 15

1
By: malathion
2018-10-03 18:46:46

1 Alternatives + Submit Alt

What Others Think

JSON file error is shown again and again in my blog if I can put this code on my website then the issue is resolved or not please tell me. This error solution is updated in ninja essays reviews website maybe some other website owners face this issue.
hopaby · 8 weeks and 3 days ago
- jq can pretty print this file using the . filter. This takes the entire input and sends it to standard output. Unless told not to jq buy Followers Australia
followerscanda9 · 6 weeks and 3 days ago
I have a pretty specific usecase, but I think it would be valuable for the tool itself. ... cat file.json | jq --validate # output message or only output on error. ... to make sure it's valid json without printing the contents to the command ...http://buyfollowersitaly.com/"> Followers italy
followerscanda9 · 6 weeks and 3 days ago
response through jq to pretty-print it. ... We can use jq to extract just the first commithttp://epicfollowers.co.uk/"> Eicfollowers uk
followerscanda9 · 6 weeks and 3 days ago
jq is like sed for JSON data - you can use it to slice and filter and map and transform ... jq can mangle the data format that you have into the one that you want with very ... array and object destructuring, a streaming parser, and a module system. http://buyfollowersitaly.com/
followerscanda9 · 6 weeks and 3 days ago
JSON stands for JavaScript Object Notation and is nearly ubiquitous as a data format, for its ... Check out the tutorial on jq herehttp://epicfollowers.co.uk/
followerscanda9 · 6 weeks and 3 days ago
I have a pretty specific usecase, but I think it would be valuable for the tool itself. ... cat file.json | jq --validate # output message or only output on error. ... to make sure it's valid json without printing the contents to the command ... by http://followersuk.co.uk/
buyfollowersuk · 5 weeks ago
A protip by originell about python, shell, zsh, vim, cli, json, commandline, and bash. ... You can pretty print (and validate) json on nearly every *nix-like (unix, linux, osx,…) system ... I use this neat little tool: www.jsonprettyprint.net. ... +1 for jq: $ echo '{"test1": 1, "test2": "win"}' | jq . The output is even colored. by https://followersuk.uk/
buyfollowersuk · 5 weeks ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: