o
    éT•j  ã                
   @   s|   d Z ddlZddlZddlZddlmZ dd„ Zedkr<zeƒ  W dS  ey; Z	 ze 
e	j¡ W Y dZ	[	dS dZ	[	ww dS )a  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)

é    N)ÚPathc                  C   sâ  d} d}t j| |d�}|jddt jdd�dtjd	� |jd
dtdd d	� |jddddd� |jddddd� |jddddd� | ¡ }|jddtdd� |jddddd d!� |jd"ddd d#d!� |jd$dd%d&� | 	¡ }|j
|j|jd'œ}|jr€d |d< d(|d)< |j�d}zJ|jr�d*d+„ |D ƒ}nt |¡f}|jd u rŸtj}n|jjd,dd�}|�}	|D ]}
tj|
|	fi |¤Ž |	 d-¡ q¬W d   ƒ n1 sÈw   Y  W n tyÞ } zt|ƒ‚d }~ww W d   ƒ d S 1 sêw   Y  d S ).Nzpython -m json.toolzZA simple command line interface for json module to validate and pretty-print JSON objects.)ÚprogÚdescriptionÚinfileú?zutf-8)Úencodingz-a JSON file to be validated or pretty-printed)ÚnargsÚtypeÚhelpÚdefaultÚoutfilez%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)Údestr   r
   z--json-linesznparse input using the JSON Lines format. Use with --no-indent or --compact to produce valid JSON Lines output.z--indenté   zJseparate items with newlines and use this number of spaces for indentation)r   r	   r
   z--tabÚstore_constÚindentú	z9separate items with newlines and use tabs for indentation)r   r   Úconstr
   z--no-indentz/separate items with spaces rather than newlinesz	--compactz1suppress all whitespace separation (most compact))r   r
   )Ú	sort_keysr   r   )ú,ú:Ú
separatorsc                 s   s   � | ]}t  |¡V  qd S )N)ÚjsonÚloads)Ú.0Úline© r   ú /usr/lib/python3.10/json/tool.pyÚ	<genexpr>A   s   € zmain.<locals>.<genexpr>ÚwÚ
)ÚargparseÚArgumentParserÚadd_argumentÚFileTypeÚsysÚstdinr   Úadd_mutually_exclusive_groupÚintÚ
parse_argsr   r   r   Úcompactr   Ú
json_linesr   Úloadr   ÚstdoutÚopenÚdumpÚwriteÚ
ValueErrorÚ
SystemExit)r   r   ÚparserÚgroupÚoptionsÚ	dump_argsr   ÚobjsÚoutr   ÚobjÚer   r   r    Úmain   s‚   
ýý
ÿ
ÿ
ÿ
ÿ
ÿ
þÿý
þÿ€€ÿ€"ñr>   Ú__main__)Ú__doc__r$   r   r(   Úpathlibr   r>   Ú__name__ÚBrokenPipeErrorÚexcÚexitÚerrnor   r   r   r    Ú<module>   s    >€ÿý