Querying JSON data
Learn how to query JSON data.
Query JSON data using dot and bracket notation to access nested fields.
Example JSON
Let’s suppose you have a JSON column payload
structured like this:
You can reference the taco_count
value inside the payload via the following syntax:
To filter on JSON columns in queries with pre-defined Metrics, first add them as dimensions to the Metric. For example, add payload
as a dimension to filter on any of its fields.
Querying JSON columns via the API
Use dot notation in API queries to reference specific JSON keys. Here’s a TimeSeries query example with filtering:
The filter uses payload.order_details.taco_count
to refer to the taco count key within payload.order_details
.
Using JSON in the console
When creating a Metric in the Console, if a column is of type JSON, it will be clearly marked. If a JSON column is selected, the text field allows for JavaScript dot and bracket notation to be entered to reference nested values.
The JavaScript dot and bracket notation is validated to make sure the syntax is correct. It is not validated against the data stored in the JSON - this is because the reference can be created before the data exists.
Property escaping
If you have a column named “foo.bar”, then you cannot reference it using foo.bar
, since this will be interpreted as JavaScript dot notation. Instead, you can use square brackets to escape the period, like this: ["foo.bar"]
.
Was this page helpful?