json_decoder_get_parse_error()

Get the location and reason for a parse error

Synopsis:

#include <sys/json.h>
json_decoder_parse_error_t json_decoder_get_parse_error(
                                                  json_decoder_t *decoder,
                                                  int *location,
                                                  const char **error);

Arguments:

decoder
The JSON decoder instance.
location
A pointer to an int that will be updated with the offset of the error in the original JSON data. If NULL, the location of the error is not written.
error
A pointer to a character buffer that will be updated with a string indicating the error type. If NULL, the error type string is not written.

Library:

libjson

Description:

If json_decoder_parse_json_str() returns a value of JSON_DECODER_PARSE_ERROR, this function will return the cause of the error and the offset in the JSON string at which the error was detected. If no parsing error occurred, this function will return JSON_DECODER_PARSE_OK and not update location.

Returns:

The parse error code (see json_decoder_parse_error_t).