How can I pretty format a JSON file, with all the correct indents and everything?
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I have a JSON file on CentOS where all text is on the same line. How can I pretty format it with all the correct indents and everything?
text-formatting json
add a comment |Â
up vote
1
down vote
favorite
I have a JSON file on CentOS where all text is on the same line. How can I pretty format it with all the correct indents and everything?
text-formatting json
1
Could you show us an example file? Does this need to be automatic? If not, just load it in a decent text editor and do it manually (in emacs, select everything andM-X indent-selection
).
â terdonâ¦
May 18 at 13:42
Have a look atjq
. Also very handy if you want to process JSON.
â dirkt
May 18 at 14:43
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have a JSON file on CentOS where all text is on the same line. How can I pretty format it with all the correct indents and everything?
text-formatting json
I have a JSON file on CentOS where all text is on the same line. How can I pretty format it with all the correct indents and everything?
text-formatting json
edited May 18 at 13:43
terdonâ¦
122k28226398
122k28226398
asked May 18 at 13:41
dr01
15.2k114768
15.2k114768
1
Could you show us an example file? Does this need to be automatic? If not, just load it in a decent text editor and do it manually (in emacs, select everything andM-X indent-selection
).
â terdonâ¦
May 18 at 13:42
Have a look atjq
. Also very handy if you want to process JSON.
â dirkt
May 18 at 14:43
add a comment |Â
1
Could you show us an example file? Does this need to be automatic? If not, just load it in a decent text editor and do it manually (in emacs, select everything andM-X indent-selection
).
â terdonâ¦
May 18 at 13:42
Have a look atjq
. Also very handy if you want to process JSON.
â dirkt
May 18 at 14:43
1
1
Could you show us an example file? Does this need to be automatic? If not, just load it in a decent text editor and do it manually (in emacs, select everything and
M-X indent-selection
).â terdonâ¦
May 18 at 13:42
Could you show us an example file? Does this need to be automatic? If not, just load it in a decent text editor and do it manually (in emacs, select everything and
M-X indent-selection
).â terdonâ¦
May 18 at 13:42
Have a look at
jq
. Also very handy if you want to process JSON.â dirkt
May 18 at 14:43
Have a look at
jq
. Also very handy if you want to process JSON.â dirkt
May 18 at 14:43
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
1
down vote
accepted
Use the package yajl
, Yet Another JSON Library. On CentOS 7 it is located in the base repo, and is most probably already installed on the machine.
To pretty-print a JSON file:
cat myfile.json | json_reformat
or simply
json_reformat < myfile.json
To verify that a file is in correct JSON syntax:
json_verify < myfile.json
add a comment |Â
up vote
1
down vote
If you don't want to install an additional package and have python available you can do:
python -m json.tool myfile.json
It also supports reading from STDIN
add a comment |Â
up vote
1
down vote
Use jq a very good JSON processor and from personal preference, its the best available in the market
for just pretty print, use
jq . file_name
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Use the package yajl
, Yet Another JSON Library. On CentOS 7 it is located in the base repo, and is most probably already installed on the machine.
To pretty-print a JSON file:
cat myfile.json | json_reformat
or simply
json_reformat < myfile.json
To verify that a file is in correct JSON syntax:
json_verify < myfile.json
add a comment |Â
up vote
1
down vote
accepted
Use the package yajl
, Yet Another JSON Library. On CentOS 7 it is located in the base repo, and is most probably already installed on the machine.
To pretty-print a JSON file:
cat myfile.json | json_reformat
or simply
json_reformat < myfile.json
To verify that a file is in correct JSON syntax:
json_verify < myfile.json
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Use the package yajl
, Yet Another JSON Library. On CentOS 7 it is located in the base repo, and is most probably already installed on the machine.
To pretty-print a JSON file:
cat myfile.json | json_reformat
or simply
json_reformat < myfile.json
To verify that a file is in correct JSON syntax:
json_verify < myfile.json
Use the package yajl
, Yet Another JSON Library. On CentOS 7 it is located in the base repo, and is most probably already installed on the machine.
To pretty-print a JSON file:
cat myfile.json | json_reformat
or simply
json_reformat < myfile.json
To verify that a file is in correct JSON syntax:
json_verify < myfile.json
edited May 18 at 13:47
answered May 18 at 13:42
dr01
15.2k114768
15.2k114768
add a comment |Â
add a comment |Â
up vote
1
down vote
If you don't want to install an additional package and have python available you can do:
python -m json.tool myfile.json
It also supports reading from STDIN
add a comment |Â
up vote
1
down vote
If you don't want to install an additional package and have python available you can do:
python -m json.tool myfile.json
It also supports reading from STDIN
add a comment |Â
up vote
1
down vote
up vote
1
down vote
If you don't want to install an additional package and have python available you can do:
python -m json.tool myfile.json
It also supports reading from STDIN
If you don't want to install an additional package and have python available you can do:
python -m json.tool myfile.json
It also supports reading from STDIN
answered May 18 at 16:25
Dalvenjia
1,14648
1,14648
add a comment |Â
add a comment |Â
up vote
1
down vote
Use jq a very good JSON processor and from personal preference, its the best available in the market
for just pretty print, use
jq . file_name
add a comment |Â
up vote
1
down vote
Use jq a very good JSON processor and from personal preference, its the best available in the market
for just pretty print, use
jq . file_name
add a comment |Â
up vote
1
down vote
up vote
1
down vote
Use jq a very good JSON processor and from personal preference, its the best available in the market
for just pretty print, use
jq . file_name
Use jq a very good JSON processor and from personal preference, its the best available in the market
for just pretty print, use
jq . file_name
answered May 18 at 16:34
mkmayank
36310
36310
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f444610%2fhow-can-i-pretty-format-a-json-file-with-all-the-correct-indents-and-everything%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
Could you show us an example file? Does this need to be automatic? If not, just load it in a decent text editor and do it manually (in emacs, select everything and
M-X indent-selection
).â terdonâ¦
May 18 at 13:42
Have a look at
jq
. Also very handy if you want to process JSON.â dirkt
May 18 at 14:43