OXIESEC PANEL
- Current Dir:
/
/
usr
/
lib
/
python2.7
/
json
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
05/09/2024 07:14:10 AM
rwxr-xr-x
📄
__init__.py
14.38 KB
03/08/2023 06:40:28 PM
rw-r--r--
📄
decoder.py
13.38 KB
03/08/2023 06:40:28 PM
rw-r--r--
📄
encoder.py
16.01 KB
03/08/2023 06:40:28 PM
rw-r--r--
📄
scanner.py
2.24 KB
03/08/2023 06:40:28 PM
rw-r--r--
📄
tool.py
997 bytes
03/08/2023 06:40:28 PM
rw-r--r--
Editing: tool.py
Close
r"""Command-line tool to validate and pretty-print JSON Usage:: $ echo '{"json":"obj"}' | python -m json.tool { "json": "obj" } $ echo '{ 1.2:3.4}' | python -m json.tool Expecting property name enclosed in double quotes: line 1 column 3 (char 2) """ import sys import json def main(): if len(sys.argv) == 1: infile = sys.stdin outfile = sys.stdout elif len(sys.argv) == 2: infile = open(sys.argv[1], 'rb') outfile = sys.stdout elif len(sys.argv) == 3: infile = open(sys.argv[1], 'rb') outfile = open(sys.argv[2], 'wb') else: raise SystemExit(sys.argv[0] + " [infile [outfile]]") with infile: try: obj = json.load(infile) except ValueError, e: raise SystemExit(e) with outfile: json.dump(obj, outfile, sort_keys=True, indent=4, separators=(',', ': ')) outfile.write('\n') if __name__ == '__main__': main()