json-prune
Last updated
Last updated
The json-prune
snippet traps calls to JSON.parse
and, if the result of the parsing is an Object, it will remove the specified properties from the result before returning to the caller.
Use json-prune
when you want to remove properties from an object parsed with JSON.parse.
Name | Description | Mandatory |
---|---|---|
The following table lists examples that use the json-override
snippet:
Filter | Result |
---|---|
The following table contains messages you'll find useful during debugging:
Message | When the message occurs | Definition |
---|---|---|
rawPrunePaths
A list of space-separated properties to remove.
Yes
rawNeedlePaths
A list of space-separated properties which must be all present for the pruning to occur. Can include placeholders {}
and []
to iterate over nested objects and arrays respectively.
No
json-prune ads
Removes any ads
property (if found) from every object parsed with JSON.parse
.
json-prune 'ads videoAds'
Removes all ads
and videoAds
properties (if found) from every object parsed with JSON.parse
.
json-prune ads userId
Removes any ads
property (if found) from every object parsed with JSON.parse
with a userId
property.
json-prune 'ads videoAds' userId
Removes all ads
and videoAds
properties (if found) from every object parsed with JSON.parse
with a userId
property.
json-prune 'ads videoAds' 'userId title'
Removes all ads
and videoAds
properties (if found) from every object parsed with JSON.parse
that has both userId
and title
properties.
json-prune data.nested.[].ad
Removes all the ad
properties listed inside an array:
before
{"data":{ "nested":[ {"ad":"delete me"}, {"ad":"delete me"}, {"ad":"delete me"}, {"not-ad":"don't delete me"}], "hello-world":"don't delete me"} }
after
{"data":{"nested":[{}, {}, {}, {"not-ad":"don't delete me"}],"hello-world":"don't delete me"}}
json-prune data.nested.{}.ad
Removes all the ad
properties listed inside an object, without mentioning the key of each object:
before
{"data": {"nested": {"item1":{}, "item2":{}, "item3":{}, "item4":{"not-ad":"don't delete me"} }, "hello-world":"don't delete me"} }
after
{"data":{"nested":{"item1":{},"item2":{},"item3":{},"item4":{"not-ad":"don't delete me"}},"hello-world":"don't delete me"}}
Wrapped JSON.parse
After JSON.parse
has been wrapped
The snippet was injected and the API was wrapped.
Iterating over array at []
or
Iterating over object at {}
The snippet is parsing the placeholder.
The path leading up to the placeholder is accurate. If a success log does not follow this, it indicates that the filter needs further refinement beyond the placeholder.
Found <<rawOverridePath>> and deleted
After a property was deleted.
A property was found and deleted. If rawOverridePaths
has multiple paths, you'll see a message for each found path.