Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../lib64/python2..../json
File: tool.py
r"""Command-line tool to validate and pretty-print JSON
[0] Fix | Delete
[1] Fix | Delete
Usage::
[2] Fix | Delete
[3] Fix | Delete
$ echo '{"json":"obj"}' | python -m json.tool
[4] Fix | Delete
{
[5] Fix | Delete
"json": "obj"
[6] Fix | Delete
}
[7] Fix | Delete
$ echo '{ 1.2:3.4}' | python -m json.tool
[8] Fix | Delete
Expecting property name enclosed in double quotes: line 1 column 3 (char 2)
[9] Fix | Delete
[10] Fix | Delete
"""
[11] Fix | Delete
import sys
[12] Fix | Delete
import json
[13] Fix | Delete
[14] Fix | Delete
def main():
[15] Fix | Delete
if len(sys.argv) == 1:
[16] Fix | Delete
infile = sys.stdin
[17] Fix | Delete
outfile = sys.stdout
[18] Fix | Delete
elif len(sys.argv) == 2:
[19] Fix | Delete
infile = open(sys.argv[1], 'rb')
[20] Fix | Delete
outfile = sys.stdout
[21] Fix | Delete
elif len(sys.argv) == 3:
[22] Fix | Delete
infile = open(sys.argv[1], 'rb')
[23] Fix | Delete
outfile = open(sys.argv[2], 'wb')
[24] Fix | Delete
else:
[25] Fix | Delete
raise SystemExit(sys.argv[0] + " [infile [outfile]]")
[26] Fix | Delete
with infile:
[27] Fix | Delete
try:
[28] Fix | Delete
obj = json.load(infile)
[29] Fix | Delete
except ValueError, e:
[30] Fix | Delete
raise SystemExit(e)
[31] Fix | Delete
with outfile:
[32] Fix | Delete
json.dump(obj, outfile, sort_keys=True,
[33] Fix | Delete
indent=4, separators=(',', ': '))
[34] Fix | Delete
outfile.write('\n')
[35] Fix | Delete
[36] Fix | Delete
[37] Fix | Delete
if __name__ == '__main__':
[38] Fix | Delete
main()
[39] Fix | Delete
[40] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function