![]() |
JSON Parser
1.0
|
| boolean json_valid_data_block | ( | const char * | json_object, |
| char ** | object_error, | ||
| unsigned long int * | line_number, | ||
| const boolean | suppress_warnings | ||
| ) |
Call the JSON syntax validator and return a boolean value based on either successful or failed validation.
The JSON data block is parsed in a linear pass, validating each character of the provided JSON data block, all tokens, values, whitespace and syntax are checked. This function, like all those in the JSON Parser Package, is fully thread safe and MP safe.
Checks are made for validity of syntax, contents, and the relative positioning of all tokens, structural, literal, object, array and value.
The contents of the character buffer will be remain unmodified. Validation only scans the JSON data block and makes no changes. If JSON errors are found a pointer to the invalid token can optionally be returned.
This JSON Validation will stop when it encounters a JSON syntax or value error, it will not perform any further validation of the data block.
If the caller does not suppress warnings, information and the location of the JSON error are written to stderr. If the caller suppressed warnings and did not know why the JSON object was rejected by the validator, call this function again without suppressing warnings to see the specific error messages involved.
| [in] | json_object | a nul terminated string containing the JSON object to validate. |
| [out] | object_error | if a syntax or value error is found in the JSON data block, a pointer the portion of the JSON data block in error is returned in this argument. This argument can be NULL in which case no pointer is returned upon encountering a JSON error. |
| [out] | line_number | if a syntax or value error is found in the JSON data block, the line number of the JSON token in error is returned in this argument. This argument can be NULL in which case no line number is returned if a JSON error was detected. |
| [in] | suppress_warnings | FALSE DO not suppress JSON error warnings written to stderr TRUE Suppress possible error warnings, no output is written. |
| TRUE | - Successful validation of the JSON object syntax, grammar and values, no language errors. |
| FALSE | - There was an error found in the JSON data block, if provided as arguments, a pointer is returned in syntax_error and an integer in line_number corresponding to the found error. If warnings were not suppressed an message detailing the JSON error was written to stderr. |