
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
U
    ¡ê,aß  ã                
   @   sj   d Z ddlZddlZddlZdd„ Zedkrfz
eƒ  W n. ek
rd Z ze ej	¡ W 5 dZ[X Y nX 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)

é    Nc                  C   s4  d} d}t j| |d�}|jddt jdd�dtjd	� |jd
dt jddd�dtjd	� |jddddd� |jddddd� | ¡ }|j}|j	}|j
}|j}|�Ž |�~ zJ|rºdd„ |D ƒ}nt |¡f}|D ] }	tj|	||dd� | d¡ qÊW n, tk
�r }
 zt|
ƒ‚W 5 d }
~
X Y nX W 5 Q R X W 5 Q R X 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ÚoutfileÚwz%write the output of infile to outfilez--sort-keysÚ
store_trueFz5sort the output of dictionaries alphabetically by key)Úactionr
   r	   z--json-linesz&parse input using the jsonlines formatc                 s   s   | ]}t  |¡V  qd S )N)ÚjsonÚloads)Ú.0Úline© r   ú./opt/alt/python38/lib64/python3.8/json/tool.pyÚ	<genexpr>,   s     zmain.<locals>.<genexpr>é   )Ú	sort_keysÚindentÚ
)ÚargparseÚArgumentParserÚadd_argumentZFileTypeÚsysÚstdinÚstdoutÚ
parse_argsr   r   r   Ú
json_linesr   ÚloadÚdumpÚwriteÚ
ValueErrorÚ
SystemExit)r   r   ÚparserZoptionsr   r   r   r!   ZobjsÚobjÚer   r   r   Úmain   sD    
ýý
ÿ
ÿr*   Ú__main__)
Ú__doc__r   r   r   r*   Ú__name__ÚBrokenPipeErrorÚexcÚexitÚerrnor   r   r   r   Ú<module>   s   $
