Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'include/zbxjson.h')
-rw-r--r--include/zbxjson.h46
1 files changed, 44 insertions, 2 deletions
diff --git a/include/zbxjson.h b/include/zbxjson.h
index 28ed6fd68a6..e5c91376b14 100644
--- a/include/zbxjson.h
+++ b/include/zbxjson.h
@@ -21,6 +21,7 @@
#define ZABBIX_ZJSON_H
#include "zbxtypes.h"
+#include "zbxalgo.h"
#define ZBX_PROTO_TAG_CLOCK "clock"
#define ZBX_PROTO_TAG_NS "ns"
@@ -250,7 +251,8 @@ typedef enum
ZBX_JSON_TYPE_OBJECT,
ZBX_JSON_TYPE_NULL,
ZBX_JSON_TYPE_TRUE,
- ZBX_JSON_TYPE_FALSE
+ ZBX_JSON_TYPE_FALSE,
+ ZBX_JSON_TYPE_NUMBER
}
zbx_json_type_t;
@@ -330,11 +332,51 @@ typedef struct
/* set to 1 when jsonpath points at single location */
unsigned char definite;
+ unsigned char first_match; /* set to 1 if first match must be returned */
}
zbx_jsonpath_t;
-void zbx_jsonpath_clear(zbx_jsonpath_t *jsonpath);
+typedef struct zbx_jsonobj zbx_jsonobj_t;
+
+ZBX_PTR_VECTOR_DECL(jsonobj_ptr, zbx_jsonobj_t *)
+
+typedef union
+{
+ char *string;
+ double number;
+ zbx_hashset_t object;
+ zbx_vector_jsonobj_ptr_t array;
+}
+zbx_jsonobj_data_t;
+
+typedef struct
+{
+ char *path; /* the path that was indexed - for example @.a.b.c */
+ zbx_hashset_t objects;
+}
+zbx_jsonobj_index_t;
+
+struct zbx_jsonobj
+{
+ zbx_json_type_t type;
+ zbx_jsonobj_data_t data;
+ zbx_jsonobj_index_t *index;
+};
+
+typedef struct
+{
+ char *name;
+ zbx_jsonobj_t value;
+}
+zbx_jsonobj_el_t;
+
int zbx_jsonpath_compile(const char *path, zbx_jsonpath_t *jsonpath);
int zbx_jsonpath_query(const struct zbx_json_parse *jp, const char *path, char **output);
+void zbx_jsonpath_clear(zbx_jsonpath_t *jsonpath);
+
+int zbx_jsonobj_open(const char *data, zbx_jsonobj_t *obj);
+void zbx_jsonobj_clear(zbx_jsonobj_t *obj);
+int zbx_jsonobj_query(zbx_jsonobj_t *obj, const char *path, char **output);
+int zbx_jsonobj_to_string(char **str, size_t *str_alloc, size_t *str_offset, zbx_jsonobj_t *obj);
#endif /* ZABBIX_ZJSON_H */