Parses a standardized JSON string into a new JSON Entity.
Returns "" if successful or an error message if not.
|Handle [OUT]||Variable to receive new handle to a JSON Entity. Required.|
|JsonString||The JSON to parse. Required.|
|ReportErrors||0 to return only success/failure; 1 to return a list of parsing errors. Optional. Added in SRP Utilities 2.0.5|
The PARSE service parses a string containing standardized JSON and produces a single JSON Entity Handle. If the JSON cannot be parsed, then this service returns a generic error message indicating that the parsing failed. If it succeeds, then "" is returns. The new JSON Entity Handle is placed into the variable you pass into the Handle parameter. It is perfectly safe to set Handle to an unassigned variable, but you should check the return value to see if the parsing was successfully, like so:
The new JSON entity's type depends upon the nature of the JSON. Here is some sample code testing each entity's type after parsing some JSON:
IMPORTANT: Any JSON entity created by this service must be deallocated from memory when no longer needed using the Release service. Forgetting to do this on occasion will not cause a fatal error since SRP Utilities will clean up all its memory when OpenInsight closes, but frequently failing to release entities causes memory to get used up, which can become a problem over long periods of time.
Normally, the parser is very forgiving. It will still parse even if there are minor errors. However, there might be times when you want to know all errors, even if the parser is able to succeed. In this case, set the ReportErrors parameter to 1 to enable this feature. When enabled, the service will return an @FM delimited list of parsing errors, or "" if there were no errors.