Gets the last known error.

Syntax

ErrorMessage = SRP_JsonX_Error()

Returns

The last known error message.

Remarks

SRP_JsonX_Error returns the last known error message. The last known error is cleared before every SRP JsonX routine is called, so if you want to know why a particular routine behaved unexpectedly, call this immediately afterward.

Error messages always begin with the "ERROR:" or "WARNING:". Errors indicate issues that prevented the API from accomplishing it's task. Warnings occur when the user provides bad input, but the API was able to recover. For example, SRP_JsonX_Begin requires you to pass '{' or '[' as the starting token. If you pass "<", then SRP_JsonX_Error will return "WARNING: '<' is not a valid token. Use '{' or '['.", yet the document will still be created with an object as the root.

Examples

$insert SRPJSONX

// There is a missing comma in this
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 := '}'

Success = SRP_JsonX_Parse('MyDocument', json)
If Success EQ 0 then
	Error = SRP_JsonX_Error()
	debug
end
SRP_JsonX_End()
  • No labels