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

jsondelete Operator (Examples)

15th January 2025 at 12:00pm

The examples below assume the following JSON object is contained in the variable object-a:

{
    "a": "one",
    "b": "",
    "c": "three",
    "d": {
        "e": "four",
        "f": [
            "five",
            "six",
            true,
            false,
            null
        ],
        "g": {
            "x": "max",
            "y": "may",
            "z": "maize"
        }
    }
}

[<object-a>jsondelete[a]]
→ Delete a top-level object property

[<object-a>jsondelete[d],[e]]
→ Delete a nested object property

[<object-a>jsondelete[d],[f],[0]]
→ Delete the first element from an array

[<object-a>jsondelete[d],[f],[-1]]
→ Delete the last element from an array using negative index

[<object-a>jsondelete[d],[f],[-2]]
→ Delete the second-to-last element from an array using negative index

[<object-a>jsondelete[d],[g],[x]]
→ Delete a deeply nested object property

[<object-a>jsondelete[]]
→ If no parameters are specified, the JSON object is returned unchanged

[<object-a>jsondelete[missing]]
→ If the property does not exist, the JSON object is returned unchanged

The examples below assume the following JSON object is contained in the variable object-b:

{"a":"one","b":"","c":1.618,"d":{"e":"four","f":["five","six",true,false,null]}}

[<object-b>jsondelete[b]]
→ Delete an empty string property

[<object-b>jsondelete[d],[f],[1]]
→ Delete a middle element from an array

The examples below assume the following JSON array is contained in the variable array-a:

["une","deux","trois",["quatre","cinq"]]

[<array-a>jsondelete[0]]
→ Delete the first element from a top-level array

[<array-a>jsondelete[-1]]
→ Delete the last element from a top-level array using negative index

[<array-a>jsondelete[3],[0]]
→ Delete an element from a nested array

[<object-a>] [<object-b>] :and[jsondelete[a]]
→ If the input consists of multiple JSON objects with matching properties, the property is deleted from all of them