Parse string values as JSON
Description
Throws an error if invalid JSON strings are encountered.
Usage
series_str_json_decode(dtype = NULL, ..., infer_schema_length = 100L)
Arguments
dtype
|
The dtype to cast the extracted value to, or NULL
(default). If NULL, the dtype will be inferred from the
JSON value.
|
…
|
These dots are for future extensions and must be empty. |
infer_schema_length
|
The maximum number of rows to scan for schema inference. If set to
NULL, the full data may be scanned (this is slow).
Only used if the dtype argument is NULL.
|
Value
A polars Series
See Also
-
\$str$json_decode()
Examples
library("polars")
s1 <- as_polars_series(c('{"a":1, "b": true}', NA, '{"a":2, "b": false}'))
s2 <- s1$str$json_decode()
s2
#> shape: (3, 1)
#> ┌───────────┐
#> │ │
#> │ --- │
#> │ struct[2] │
#> ╞═══════════╡
#> │ {1,true} │
#> │ null │
#> │ {2,false} │
#> └───────────┘
#> Struct(`a`=Int64, `b`=Boolean)
#> shape: (3, 1)
#> ┌───────────┐
#> │ │
#> │ --- │
#> │ struct[2] │
#> ╞═══════════╡
#> │ {1,true} │
#> │ null │
#> │ {2,false} │
#> └───────────┘
#> Struct(`a`=UInt8, `b`=Boolean)