class_docstr: Namespace for string related expressions.
class_docstr_tok: ["Namespace","for","string","related","expressions","."]
docstr: Parse string values as JSON.
  
  Throws an error if invalid JSON strings are encountered.
  
  Parameters
  ----------
  dtype
      The dtype to cast the extracted value to. If None, the dtype will be
      inferred from the JSON value.
  infer_schema_length
      How many rows to parse to determine the schema.
      If `None` all rows are used.
  
  See Also
  --------
  json_path_match : Extract the first match of json string with provided JSONPath
      expression.
  
  Examples
  --------
  >>> df = pl.DataFrame(
  ...     {"json": ['{"a":1, "b": true}', None, '{"a":2, "b": false}']}
  ... )
  >>> dtype = pl.Struct([pl.Field("a", pl.Int64), pl.Field("b", pl.Boolean)])
  >>> df.with_columns(decoded=pl.col("json").str.json_decode(dtype))
  shape: (3, 2)
  ┌─────────────────────┬─────────────┐
  │ json                ┆ decoded     │
  │ ---                 ┆ ---         │
  │ str                 ┆ struct[2]   │
  ╞═════════════════════╪═════════════╡
  │ {"a":1, "b": true}  ┆ {1,true}    │
  │ null                ┆ {null,null} │
  │ {"a":2, "b": false} ┆ {2,false}   │
  └─────────────────────┴─────────────┘
docstr_tok: ["Parse","string","values","as","JSON",".","Throws","an","error","if","invalid","JSON","strings","are","encountered",".","Parameters","--","--","--","--","--","dtype","The","dtype","to","cast","the","extracted","value","to",".","If","None",",","the","dtype","will","be","inferred","from","the","JSON","value",".","infer_schema_length","How","many","rows","to","parse","to","determine","the","schema",".","If","`","None","`","all","rows","are","used",".","See","Also","--","--","--","--","json_path_match",":","Extract","the","first","match","of","json","string","with","provided","JSONPath","expression",".","Examples","--","--","--","--",">",">",">","df","=","pl.DataFrame","(","...","{","``","json","''",":","[","'","{","``","a","''",":1",",","``","b","''",":","true","}","'",",","None",",","'","{","``","a","''",":2",",","``","b","''",":","false","}","'","]","}","...",")",">",">",">","dtype","=","pl.Struct","(","[","pl.Field","(","``","a","''",",","pl.Int64",")",",","pl.Field","(","``","b","''",",","pl.Boolean",")","]",")",">",">",">","df.with_columns","(","decoded=pl.col","(","``","json","''",")",".str.json_decode","(","dtype",")",")","shape",":","(","3",",","2",")","\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u252c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510","\u2502","json","\u2506","decoded","\u2502","\u2502","--","-","\u2506","--","-","\u2502","\u2502","str","\u2506","struct","[","2","]","\u2502","\u255e\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u256a\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2561","\u2502","{","``","a","''",":1",",","``","b","''",":","true","}","\u2506","{","1",",","true","}","\u2502","\u2502","null","\u2506","{","null",",","null","}","\u2502","\u2502","{","``","a","''",":2",",","``","b","''",":","false","}","\u2506","{","2",",","false","}","\u2502","\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"]
code: def json_decode(
      self,
      dtype: PolarsDataType | None = None,
      infer_schema_length: int | None = 100,
  ) -> Expr:
      """
      Parse string values as JSON.
  
      Throws an error if invalid JSON strings are encountered.
  
      Parameters
      ----------
      dtype
          The dtype to cast the extracted value to. If None, the dtype will be
          inferred from the JSON value.
      infer_schema_length
          How many rows to parse to determine the schema.
          If `None` all rows are used.
  
      See Also
      --------
      json_path_match : Extract the first match of json string with provided JSONPath
          expression.
  
      Examples
      --------
      >>> df = pl.DataFrame(
      ...     {"json": ['{"a":1, "b": true}', None, '{"a":2, "b": false}']}
      ... )
      >>> dtype = pl.Struct([pl.Field("a", pl.Int64), pl.Field("b", pl.Boolean)])
      >>> df.with_columns(decoded=pl.col("json").str.json_decode(dtype))
      shape: (3, 2)
      ┌─────────────────────┬─────────────┐
      │ json                ┆ decoded     │
      │ ---                 ┆ ---         │
      │ str                 ┆ struct[2]   │
      ╞═════════════════════╪═════════════╡
      │ {"a":1, "b": true}  ┆ {1,true}    │
      │ null                ┆ {null,null} │
      │ {"a":2, "b": false} ┆ {2,false}   │
      └─────────────────────┴─────────────┘
  
      """
      if dtype is not None:
          dtype = py_type_to_dtype(dtype)
      return wrap_expr(
          self._pyexpr.str_json_decode(dtype, infer_schema_length)
      )
  
imports: from __future__ import annotations
  import warnings
  from typing import TYPE_CHECKING
  import polars._reexport
  from polars import functions
  from polars.datatypes import Date, Datetime, Int32, Time, py_type_to_dtype
  from polars.exceptions import ChronoFormatWarning
  from polars.utils._parse_expr_input import parse_as_expression
  from polars.utils._wrap import wrap_expr
  from polars.utils.deprecation import deprecate_renamed_function, deprecate_renamed_parameter, rename_use_earliest_to_ambiguous
  from polars.utils.various import find_stacklevel
label_desc: Use image node_id 24 for calling the ExprStringNameSpace obj's underlying member method code with example usage: obj.json_decode(dtype, infer_schema_length) and returns: wrap_expr