diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-07-24 09:54:23 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-07-24 09:54:44 +0000 |
commit | 836b47cb7e99a977c5a23b059ca1d0b5065d310e (patch) | |
tree | 1604da8f482d02effa033c94a84be42bc0c848c3 /libnetdata/json/json.h | |
parent | Releasing debian version 1.44.3-2. (diff) | |
download | netdata-836b47cb7e99a977c5a23b059ca1d0b5065d310e.tar.xz netdata-836b47cb7e99a977c5a23b059ca1d0b5065d310e.zip |
Merging upstream version 1.46.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'libnetdata/json/json.h')
-rw-r--r-- | libnetdata/json/json.h | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/libnetdata/json/json.h b/libnetdata/json/json.h deleted file mode 100644 index b43f06b5..00000000 --- a/libnetdata/json/json.h +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef CHECKIN_JSON_H -#define CHECKIN_JSON_H 1 - - -#if ENABLE_JSONC -#include <json-c/json.h> -// fix an older json-c bug -// https://github.com/json-c/json-c/issues/135 -#ifdef error_description -#undef error_description -#endif // error_description -#endif // ENABLE_JSONC - -#include "jsmn.h" - -//https://www.ibm.com/support/knowledgecenter/en/SS9H2Y_7.6.0/com.ibm.dp.doc/json_parserlimits.html -#define JSON_NAME_LEN 256 -#define JSON_FULLNAME_LEN 1024 - -typedef enum { - JSON_OBJECT = 0, - JSON_ARRAY = 1, - JSON_STRING = 2, - JSON_NUMBER = 3, - JSON_BOOLEAN = 4, - JSON_NULL = 5, -} JSON_ENTRY_TYPE; - -typedef struct json_entry { - JSON_ENTRY_TYPE type; - char name[JSON_NAME_LEN + 1]; - char fullname[JSON_FULLNAME_LEN + 1]; - union { - char *string; // type == JSON_STRING - NETDATA_DOUBLE number; // type == JSON_NUMBER - int boolean; // type == JSON_BOOLEAN - size_t items; // type == JSON_ARRAY - } data; - size_t pos; // the position of this item in its parent - - char *original_string; - - void *callback_data; - int (*callback_function)(struct json_entry *); -} JSON_ENTRY; - -// ---------------------------------------------------------------------------- -// public functions - -#define JSON_OK 0 -#define JSON_CANNOT_DOWNLOAD 1 -#define JSON_CANNOT_PARSE 2 - -int json_parse(char *js, void *callback_data, int (*callback_function)(JSON_ENTRY *)); - - -// ---------------------------------------------------------------------------- -// private functions - -#ifdef ENABLE_JSONC -json_object *json_tokenise(char *js); -size_t json_walk(json_object *t, void *callback_data, int (*callback_function)(struct json_entry *)); -#else -jsmntok_t *json_tokenise(char *js, size_t len, size_t *count); -size_t json_walk_tree(char *js, jsmntok_t *t, void *callback_data, int (*callback_function)(struct json_entry *)); -#endif - -size_t json_walk_object(char *js, jsmntok_t *t, size_t nest, size_t start, JSON_ENTRY *e); -size_t json_walk_array(char *js, jsmntok_t *t, size_t nest, size_t start, JSON_ENTRY *e); -size_t json_walk_string(char *js, jsmntok_t *t, size_t start, JSON_ENTRY *e); -size_t json_walk_primitive(char *js, jsmntok_t *t, size_t start, JSON_ENTRY *e); - -int json_callback_print(JSON_ENTRY *e); - - - -#endif
\ No newline at end of file |