This might be a stupid question.
this is my first day using sublime
I install the pretty json and when i press ctr+alt+j
it makes the jason look very pretty.
is there a way that i do it in a scrpt so all my json files look pretty?
This might be a stupid question.
this is my first day using sublime
I install the pretty json and when i press ctr+alt+j
it makes the jason look very pretty.
is there a way that i do it in a scrpt so all my json files look pretty?
You’ll need to clarify on the “all […] files” part. All currently open JSON files? Should all json files be prettified automatically when you open them? Do you mean all JSON files in a certain directory?
sorry for confusion…
here is what i mean:
I have a bunch of json files like this
if i open each of them, and do ctr+alt+j and it become pretty
i have 2k images so i dont want to do it single by single for each images.
is there any easier way to do it?
thanks
Sounds like a job for a small script (or shell command). If you have Python 3.4+ installed, you can just use the following (save and execute it in the folder you want it to work in):
import json
from pathlib import Path
for path in Path().glob("*.json"):
with path.open('r+') as f:
data = json.load(f)
f.truncate(0)
json.dump(data, f, indent=4)