Links
Comment on page

json-override

The json-override snippet wraps JSON.parse to override values from the same list as override-property-read.

Parameters

Name
Description
Mandatory
rawOverridePaths
A list of space-separated properties to remove. It also accepts property chains, like foo.bar.tar.
Yes
value
The value to override the property with.
Yes
rawNeedlePaths
A list of space-separated properties. All must be present for pruning to occur. Also accepts property chains.
No
filter
A string to look for in the raw string, before it's passed to JSON.parse. If no match is found, no further search is done on the resulting object.
If the string begins and ends with a slash (/), the text in between is treated as a regular expression.
No

Possible override values

Value
Definition
undefined
false
true
null
" "
An empty string
decimal integer
noopFunc
A function with an empty body
trueFunc
A function that returns true
emptyArray
An array with no elements
emptyObj
An object with no properties

Filter examples

The following table lists examples that use the json-override snippet:
Filter
Result
json-override ghl_label ''
Replaces the ghl_label property value (if found) with an empty string from every object parsed with JSON.parse.
json-override 'children text' ''
Replaces all children and text property values (if found) with an empty string from every object parsed with JSON.parse.
json-override ghl_label '' text
Replaces any ghl_label property value (if found) with an empty string from every object that has a text property and is parsed with JSON.parse.
json-override 'children text' '' 'styles tag'
Replaces all children and text property values (if found) from every object that has both the styles and tag properties and is parsed with JSON.parse.
json-override ghl_label.children '' '' 'test'
Replaces the children sub-property value of a ghl_label property (if found) with an empty string only if the raw string contains test from every object that is parsed with JSON.parse.

Debugging

The following table contains messages you'll find useful during debugging:
Message
When the message occurs
Definition
Wrapped JSON.parse
After JSON.parse has been wrapped
The snippet was injected and the API was wrapped.
Found <<rawOverridePath>> replaced it with <<value>>
After a property was overridden.
A property was found and overridden. If rawOverridePaths has multiple paths, you'll see a message for each found path.
Last modified 9mo ago