| purpose | delete a property from JSON objects |
|---|---|
| input | a selection of JSON objects |
| parameter | one or more indexes of the property to delete |
| output | the JSON objects with the specified property deleted |
Learn more about how to use Filters
New in v5.4.0 The jsondelete operator is used to delete a property from JSON strings. See JSON in TiddlyWiki for background. See also the following related operators:
jsonsetto set values within JSON objectsjsongetto retrieve the values of a property in JSON datajsontypeto retrieve the type of a JSON valuejsonindexesto retrieve the names of the fields of a JSON object, or the indexes of a JSON arrayjsonextractto retrieve a JSON value as a string of JSON
Properties within a JSON object are identified by a sequence of indexes. In the following example, the value at [a] is one, and the value at [d][f][0] is five.
{
"a": "one",
"b": "",
"c": "three",
"d": {
"e": "four",
"f": [
"five",
"six",
true,
false,
null
],
"g": {
"x": "max",
"y": "may",
"z": "maize"
}
}
}The jsondelete operator uses multiple parameters to specify the indexes of the property to delete. For object properties, the property is removed using JavaScript's delete operator. For array elements, the element is removed using splice, which shifts remaining elements.
Negative indexes into an array are counted from the end, so -1 means the last item, -2 the next-to-last item, and so on.
Indexes can be dynamically composed from variables and transclusions, e.g. [<jsondata>jsondelete<variable>,{!!field},[0]].
If the specified property does not exist, the JSON object is returned unchanged. If you attempt to delete the root object itself (by providing no indexes or a blank index), the JSON object is returned unchanged.
If the input consists of multiple JSON objects, the property is deleted from all of them.