json-prune
The json-prune snippet traps calls to JSON.parse and, if the result is an Object, removes the specified properties from the result before returning to the caller.
It wraps both JSON.parse and Response.prototype.json, so a payload is covered whether the page parses it itself or reads it straight off a fetch response with await response.json().
Parameters
|
Name |
Description |
Mandatory |
|---|---|---|
|
|
Space-separated properties to remove. Accepts |
Yes |
|
|
Space-separated properties which must all be present for pruning to occur. |
No |
|
|
Space-separated strings or regex which must be present in the call stack. |
No |
JSONPath mode
When an entry in rawPrunePaths starts with jsonpath(, the query is evaluated against the parsed object and every property it matches is deleted. Use it when the placeholder syntax cannot express the shape you need — for example filtering on a sibling property's value, or matching at an unknown depth with $... For simple fixed paths, the dotted and placeholder forms remain easier to read.
-
rawPrunePathsis split on spaces, so a query must not contain spaces. -
Quotes inside a filter expression must be written
\', or the parser strips them. -
Entries are evaluated independently, so plain properties and queries can be mixed in one filter.
-
For the supported query syntax, see JSONPath evaluator. For the escaping rules, see Snippets Overview.
Filter examples
|
Filter |
Result |
|---|---|
|
|
Removes any |
|
|
Removes all |
|
|
Removes |
|
|
Removes all |
|
|
Removes all |
|
|
Removes array elements that have an |
|
|
Removes object properties that contain the property |
|
|
Removes |
|
|
JSONPath mode. Removes every |
|
|
Removes every element of |
|
|
Mixes forms: prunes via the query and via the plain |
Debugging
|
Message |
When |
Definition |
|---|---|---|
|
|
After wrapping |
The API was wrapped. |
|
|
After wrapping |
Payloads read via |
|
|
After comparing stack trace |
The needle was found. |
|
|
After deletion |
A property was found and deleted. |
|
|
Right after the snippet fires |
The query could not be compiled, so that entry will never match. |
|
|
Per matched property |
A property matched the query and was deleted. One message per match. |
|
|
Evaluating a compiled query threw |
That object is left untouched. |