json-prune

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.

Parameters

Name

Description

Mandatory

rawPrunePaths

Space-separated properties to remove.

Yes

rawNeedlePaths

Space-separated properties which must all be present for pruning to occur. Accepts {} and [] placeholders.

No

rawNeedleStack

Space-separated strings or regex which must be present in the call stack.

No

Filter examples

Filter

Result

json-prune ads

Removes any ads property from every object parsed with JSON.parse.

json-prune 'ads videoAds'

Removes all ads and videoAds properties.

json-prune ads userId

Removes ads from every object with a userId property.

json-prune data.nested.[].ad

Removes all ad properties listed inside an array.

json-prune data.nested.{}.ad

Removes all ad properties listed inside nested objects.

json-prune data.nested.[-].elem.ad

Removes array elements that have an ad property.

json-prune data.nested.{-}.ad

Removes object properties that contain the property ad.

json-prune ads '' functionName

Removes ads if functionName is found in the call stack.

Debugging

Message

When

Definition

Wrapped JSON.parse

After wrapping

The API was wrapped.

Found needle in stack trace: <<rawNeedleStack>>

After comparing stack trace

The needle was found.

Found <<rawPrunePaths>> and deleted.

After deletion

A property was found and deleted.