cudf.core.accessors.string.StringMethods.get_json_object#

StringMethods.get_json_object(json_path: str, *, allow_single_quotes: bool = False, strip_quotes_from_single_strings: bool = True, missing_fields_as_nulls: bool = False) Series | Index[source]#

Applies a JSONPath string to an input strings column where each row in the column is a valid json string

Parameters:
json_pathstr

The JSONPath string to be applied to each row of the input column

allow_single_quotesbool, default False

If True, representing strings with single quotes is allowed. If False, strings must only be represented with double quotes.

strip_quotes_from_single_stringsbool, default True

If True, strip the quotes from the return value of a given row if it is a string. If False, values returned for a given row include quotes if they are strings.

missing_fields_as_nullsbool, default False

If True, when an object is queried for a field it does not contain, “null” is returned. If False, when an object is queried for a field it does not contain, None is returned.

Returns:
Column: New strings column containing the retrieved json object strings

Examples

>>> import cudf
>>> series = cudf.Series(
...     [
...         '{"store":{"book":[{"category":"reference",'
...         '"author":"Nigel Rees","title":"Sayings of the Century",'
...         '"price":8.95},{"category":"fiction",'
...         '"author":"Evelyn Waugh","title":"Sword of Honour",'
...         '"price":12.99}]}}'
...     ]
... )
>>> series.str.get_json_object("$.store.book")
0    [{"category":"reference","author":"Nigel Rees"...
dtype: object