Deletes all elements in an object or array.

Syntax

SRP_JsonX_Clear(Path)

Returns

1 if successful, 0 if there was an error.

Parameters

ParameterDescription
PathPath to an object or array whose elements to delete.

Remarks

SRP_JsonX_Clear clears all elements out of the object or array pointed to by Path. See Paths for more details.

Examples

$insert SRPJSONX

Json  = '{'
Json := '    "employees": ['
Json := '        {'
Json := '            "firstname": "John",'
Json := '            "lastname": "Doe",'
Json := '            "age": 21'
Json := '        },'
Json := '        {'
Json := '            "firstname": "Anna",'
Json := '            "lastname": "Smith",'
Json := '            "age": 32'
Json := '        },'
Json := '        {'
Json := '            "firstname": "Peter",'
Json := '            "lastname": "Jones",'
Json := '            "age": 43'
Json := '        }'
Json := '    ],'
Json := '    "nums": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10],'
Json := '    "active": true,'
Json := '    "alwaysnull": null,'
Json := '    "alwaysstring": "4.321"'
Json := '}'

SRP_JsonX_Parse('MyDocument', json)

	// Remove all members of the second employee
    SRP_JsonX_Clear('employees[2]')

	// Remove all numbers from the nums array
	SRP_JsonX_Clear('nums')

NewJson = SRP_JsonX_End('Pretty')
  • No labels