f dZddlZddlZddlZddlmZdZedk(r eyy#e$r&Z eje jYdZ [ ydZ [ wwxYw)aCommand-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) N)Pathcd}d}tj||}|jddtjddtj |jd dt d d |jd d dd|jdddd|jdd dd|j}|jddtd|jddddd !|jd"dddd#!|jd$d d%&|j}|j|j|jd'}|jr d|d<d(|d)<|j5} |jr d*|D}nt!j"|f}|j$tj&}n|j$j)d+d}|5} |D]*} t!j*| | fi|| j-d,, ddddddy#1swYxYw#t.$r} t1| d} ~ wwxYw#1swYyxYw)-Nzpython -m json.toolzZA simple command line interface for json module to validate and pretty-print JSON objects.)prog descriptioninfile?zutf-8)encodingz-a JSON file to be validated or pretty-printed)nargstypehelpdefaultoutfilez%write the output of infile to outfilez --sort-keys store_trueFz5sort the output of dictionaries alphabetically by key)actionr r z--no-ensure-ascii ensure_ascii store_falsez(disable escaping of non-ASCII characters)destrr z --json-linesznparse input using the JSON Lines format. Use with --no-indent or --compact to produce valid JSON Lines output.z--indentzJseparate items with newlines and use this number of spaces for indentation)r r r z--tab store_constindent z9separate items with newlines and use tabs for indentation)rrconstr z --no-indentz/separate items with spaces rather than newlinesz --compactz1suppress all whitespace separation (most compact))rr ) sort_keysrr),: separatorsc3FK|]}tj|yw)N)jsonloads).0lines /usr/lib/python3.12/json/tool.py zmain..AsrKs^  ; | z  s'AA  A