Function readJSON

  • Read a JSON file or string into a DataFrame.

    Parameters

    • pathOrBody: string | Buffer

      path or buffer or string

      • path: Path to a file or a file like string. Any valid filepath can be used. Example: file.csv.
      • body: String or buffer to be read as a CSV
    • Optional options: Partial<ReadJsonOptions>

    Returns pl.DataFrame

    (DataFrame)

    Example

    const jsonString = `
    {"a", 1, "b", "foo", "c": 3}
    {"a": 2, "b": "bar", "c": 6}
    `
    > const df = pl.readJSON(jsonString)
    > console.log(df)
    shape: (2, 3)
    ╭─────┬─────┬─────╮
    abc
    │ --- ┆ --- ┆ --- │
    i64stri64
    ╞═════╪═════╪═════╡
    1foo3
    ├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┤
    2bar6
    ╰─────┴─────┴─────╯