Breadcrumbs

JSONPath evaluator

Overview

A lightweight JSONPath engine is supported within the json-prune, json-override, replace-xhr-response, and replace-xhr-request snippets. This allows for precise targeting of properties within JSON objects using standard path notation.

To use JSONPath in a filter, prefix the path argument with jsonpath(. If the prefix is omitted, the snippet falls back to its standard behaviour.

Supported Syntax

Operator

Name

Description

Example

$

Root

Represents the root object of the JSON structure.

$.data

.

Dot Access

Accesses a child property by name.

$.store.book

..

Recursive descent

Searches for a key at any level of the hierarchy.


$..ad_id

*

Wildcard

Matches all child properties or array elements.

$.items[*]

[]

Bracket notation

Used for keys with special characters, indexes, or filter expressions.

$['complex-key']

[?()]

Filter expression

Filters objects based on a property comparison.

[?(@.type=='ad')]

Filter Comparison Operators

Within a [?()] expression, the following comparison operators are supported:

  • Equality / Inequality: ==, !=

  • Numeric / Lexical: <, <=, >, >=

  • String matching: ^= (starts with), $= (ends with), *= (contains)

Examples

Filter

Result

example.com#$#json-prune jsonpath($..ad_tracking)

Removes every instance of ad_tracking found at any depth.

example.com#$#json-override jsonpath($.items[(@.is_sponsored==true)].label) "Clean Content"

Overrides the label property to "Clean Content" only on items where is_sponsored is true.

example.com#$#json-prune jsonpath($.metadata.*)

Removes all properties within the metadata object.

example.com#$#json-prune jsonpath($..trackingId)

Removes every instance of trackingId at any depth.

example.com#$#json-override jsonpath($.ads[?(@.type=='banner')].visible) false

Sets visible to false on all banner-type ad objects.