Source
return json_error("invalid object format, expected opening character '{' or '['", start, error);
/*
** Zabbix
** Copyright (C) 2001-2023 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
/******************************************************************************
* *
* Purpose: Prepares JSON parsing error message *
* *
* Parameters: message - [IN] the error message *
* ptr - [IN] the failing data fragment *
* error - [OUT] the parsing error message (can be NULL) *
* *
* Return value: 0 - the json_error() function always returns 0 value *
* so it can be used to return from failed parses *
* *
******************************************************************************/
zbx_int64_t json_error(const char *message, const char *ptr, char **error)
{
if (NULL != error)
{
if (NULL != ptr)
{
if (128 < strlen(ptr))
*error = zbx_dsprintf(*error, "%s at: '%128s...'", message, ptr);
else
*error = zbx_dsprintf(*error, "%s at: '%s'", message, ptr);
}
else
*error = zbx_strdup(*error, message);
}
return 0;
}
/******************************************************************************
* *
* Purpose: Parses JSON string value or object name *
* *
* Parameters: start - [IN] the JSON data without leading whitespace *
* str - [OUT] the parsed unquoted string (can be NULL) *
* error - [OUT] the parsing error message (can be NULL) *
* *