This page is part of a static HTML representation of the TiddlyWiki at https://tiddlywiki.com/

jsondelete Operator

15th January 2025 at 12:00pm
purposedelete a property from JSON objects
inputa selection of JSON objects
parameterone or more indexes of the property to delete
outputthe 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:

  • jsonset to set values within JSON objects
  • jsonget to retrieve the values of a property in JSON data
  • jsontype to retrieve the type of a JSON value
  • jsonindexes to retrieve the names of the fields of a JSON object, or the indexes of a JSON array
  • jsonextract to 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.

Examples