
    q-Ph                        d dl mZ d dlZd dlmZmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ d dlmZ  ej        e          5  d d	lmZ ddd           n# 1 swxY w Y   e	rd d
lmZ d dlmZ d dlmZ ddedddZdS )    )annotationsN)BytesIOStringIO)Path)TYPE_CHECKING)normalize_filepath)wrap_df)N_INFER_DEFAULT)PyDataFrame)IOBase)	DataFrame)SchemaDefinition)schemaschema_overridesinfer_schema_lengthsourcestr | Path | IOBase | bytesr   SchemaDefinition | Noner   r   
int | Nonereturnr   c               8   t          | t                    r4t          |                                                                           } n+t          | t
          t          f          rt          |           } t          j	        | |||          }t          |          S )u	  
    Read into a DataFrame from a JSON file.

    Parameters
    ----------
    source
        Path to a file or a file-like object (by "file-like object" we refer to objects
        that have a `read()` method, such as a file handler like the builtin `open`
        function, or a `BytesIO` instance). For file-like objects, the stream position
        may not be updated accordingly after reading.
    schema : Sequence of str, (str,DataType) pairs, or a {str:DataType,} dict
        The DataFrame schema may be declared in several ways:

        * As a dict of {name:type} pairs; if type is None, it will be auto-inferred.
        * As a list of column names; in this case types are automatically inferred.
        * As a list of (name,type) pairs; this is equivalent to the dictionary form.

        If you supply a list of column names that does not match the names in the
        underlying data, the names given here will overwrite them. The number
        of names given in the schema should match the underlying data dimensions.
    schema_overrides : dict, default None
        Support type specification or override of one or more columns; note that
        any dtypes inferred from the schema param will be overridden.
    infer_schema_length
        The maximum number of rows to scan for schema inference.
        If set to `None`, the full data may be scanned *(this is slow)*.

    See Also
    --------
    read_ndjson

    Examples
    --------
    >>> from io import StringIO
    >>> json_str = '[{"foo":1,"bar":6},{"foo":2,"bar":7},{"foo":3,"bar":8}]'
    >>> pl.read_json(StringIO(json_str))
    shape: (3, 2)
    ┌─────┬─────┐
    │ foo ┆ bar │
    │ --- ┆ --- │
    │ i64 ┆ i64 │
    ╞═════╪═════╡
    │ 1   ┆ 6   │
    │ 2   ┆ 7   │
    │ 3   ┆ 8   │
    └─────┴─────┘

    With the schema defined.

    >>> pl.read_json(StringIO(json_str), schema={"foo": pl.Int64, "bar": pl.Float64})
    shape: (3, 2)
    ┌─────┬─────┐
    │ foo ┆ bar │
    │ --- ┆ --- │
    │ i64 ┆ f64 │
    ╞═════╪═════╡
    │ 1   ┆ 6.0 │
    │ 2   ┆ 7.0 │
    │ 3   ┆ 8.0 │
    └─────┴─────┘
    )r   r   r   )
isinstancer   r   getvalueencodestrr   r   r   	read_jsonr	   )r   r   r   r   pydfs        S/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/polars/io/json/read.pyr   r      s    H &(## ,**113344	FS$K	(	( ,#F++ /)	  D 4==    )
r   r   r   r   r   r   r   r   r   r   )
__future__r   
contextlibior   r   pathlibr   typingr   polars._utils.variousr   polars._utils.wrapr	   polars.datatypesr
   suppressImportErrorpolars.polarsr   r   polarsr   polars._typingr   r    r   r   <module>r.      s   " " " " " "                                       4 4 4 4 4 4 & & & & & & , , , , , ,Z%% * *))))))* * * * * * * * * * * * * * *  0      ////// '+04&5O O O O O O O Os   AAA