bigframes.bigquery.json_query#

bigframes.bigquery.json_query(input: Series, json_path: str) Series[source]#

Extracts a JSON value and converts it to a SQL JSON-formatted STRING or JSON value. This function uses double quotes to escape invalid JSONPath characters in JSON keys. For example: "a.b".

Examples:

>>> import bigframes.pandas as bpd
>>> import bigframes.bigquery as bbq
>>> s = bpd.Series(['{"class": {"students": [{"id": 5}, {"id": 12}]}}'])
>>> bbq.json_query(s, json_path="$.class")
0    {"students":[{"id":5},{"id":12}]}
dtype: string
Parameters:
  • input (bigframes.series.Series) – The Series containing JSON data (as native JSON objects or JSON-formatted strings).

  • json_path (str) – The JSON path identifying the data that you want to obtain from the input.

Returns:

A new Series with the JSON or JSON-formatted STRING.

Return type:

bigframes.series.Series