Gets all an object's or array's values.

Syntax

Values = SRP_JsonX_Values(Path, Delim, DefaultIfNull)

Returns

The object's or array's values.

Parameters

ParameterDescription
PathPath to an object whose values to get.
DelimThe delimiter to use in the final value list. Optional. Default is @FM
DefaultIfNullThe value to return if a value is null. Optional. Default is ""

Remarks

SRP_JsonX_Values gets the list of values of the object or array pointed to by Path. See Paths for more details. The list only contains values, so this routine is less useful when applied to objects. By default, the list is @FM delimited, but you can use the Delim parameter to set your preferred delimiter.

Any null value will be added to the list as an empty string. If you'd prefer something different, set the DefaultIfNull parameter to your preferred value.

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)
	Values = SRP_JsonX_Values('nums', ',')
SRP_JsonX_End()
  • No labels