Wireshark 5.1.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
wsjson.h
Go to the documentation of this file.
1
13
14#pragma once
15
16#include "ws_symbol_export.h"
17
18#include <inttypes.h>
19#include <stdbool.h>
20
21#include "jsmn.h"
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
38WS_DLL_PUBLIC bool json_validate(const uint8_t *buf, const size_t len);
39
52WS_DLL_PUBLIC int json_parse(const char *buf, jsmntok_t *tokens, unsigned int max_tokens);
53
68WS_DLL_PUBLIC int json_parse_len(const char *buf, size_t len, jsmntok_t *tokens, unsigned int max_tokens);
69
78WS_DLL_PUBLIC jsmntok_t *json_get_object(const char *buf, jsmntok_t *parent, const char *name);
79
88WS_DLL_PUBLIC jsmntok_t *json_get_array(const char *buf, jsmntok_t *parent, const char *name);
89
96WS_DLL_PUBLIC int json_get_array_len(jsmntok_t *array);
97
109WS_DLL_PUBLIC jsmntok_t *json_get_array_index(jsmntok_t *parent, int idx);
110
130WS_DLL_PUBLIC jsmntok_t *json_get_next_object(jsmntok_t *cur);
131
142WS_DLL_PUBLIC char *json_get_string(char *buf, jsmntok_t *parent, const char *name);
143
155WS_DLL_PUBLIC bool json_get_double(char *buf, jsmntok_t *parent, const char *name, double *val);
156
168WS_DLL_PUBLIC bool json_get_int(char *buf, jsmntok_t *parent, const char *name, int64_t *val);
169
181WS_DLL_PUBLIC bool json_get_boolean(char *buf, jsmntok_t *parent, const char *name, bool *val);
182
189WS_DLL_PUBLIC bool json_decode_string_inplace(char *text);
190
205WS_DLL_PUBLIC bool json_strip_jsonc_comments(char *text);
206
207#ifdef __cplusplus
208}
209#endif
210
211/*
212 * Editor modelines - https://www.wireshark.org/tools/modelines.html
213 *
214 * Local variables:
215 * c-basic-offset: 4
216 * tab-width: 8
217 * indent-tabs-mode: nil
218 * End:
219 *
220 * vi: set shiftwidth=4 tabstop=8 expandtab:
221 * :indentSize=4:tabSize=8:noTabs=true:
222 */
Definition jsmn.h:69
WS_DLL_PUBLIC bool json_validate(const uint8_t *buf, const size_t len)
Check if a buffer is valid JSON.
Definition wsjson.c:27
WS_DLL_PUBLIC bool json_get_double(char *buf, jsmntok_t *parent, const char *name, double *val)
Get the value of a number object belonging to the parent object and named as the name variable.
Definition wsjson.c:188
WS_DLL_PUBLIC bool json_strip_jsonc_comments(char *text)
Strip the comments from a JSONC (jsonc.org) string in place, so that it can be parsed with json_parse...
Definition wsjson.c:370
WS_DLL_PUBLIC char * json_get_string(char *buf, jsmntok_t *parent, const char *name)
Get the unescaped value of a string object belonging to the parent object and named as the name varia...
Definition wsjson.c:168
WS_DLL_PUBLIC int json_parse(const char *buf, jsmntok_t *tokens, unsigned int max_tokens)
Parse a JSON string and write the token's addresses into the tokens array.
Definition wsjson.c:88
WS_DLL_PUBLIC bool json_decode_string_inplace(char *text)
Decode the contents of a JSON string value by overwriting the input data.
Definition wsjson.c:266
WS_DLL_PUBLIC int json_get_array_len(jsmntok_t *array)
Get the number of elements of an array.
Definition wsjson.c:148
WS_DLL_PUBLIC bool json_get_int(char *buf, jsmntok_t *parent, const char *name, int64_t *val)
Get the value of a number object belonging to the parent object and named as the name variable.
Definition wsjson.c:210
WS_DLL_PUBLIC int json_parse_len(const char *buf, size_t len, jsmntok_t *tokens, unsigned int max_tokens)
Parse a JSON buffer and write the token's addresses into the tokens array.
Definition wsjson.c:97
WS_DLL_PUBLIC jsmntok_t * json_get_object(const char *buf, jsmntok_t *parent, const char *name)
Get the pointer to an object belonging to the parent object and named as the name variable.
Definition wsjson.c:114
WS_DLL_PUBLIC bool json_get_boolean(char *buf, jsmntok_t *parent, const char *name, bool *val)
Get the value of a boolean belonging to the parent object and named as the name variable.
Definition wsjson.c:228
WS_DLL_PUBLIC jsmntok_t * json_get_next_object(jsmntok_t *cur)
Get the pointer to the next JSON element which is a sibling of cur.
Definition wsjson.c:105
WS_DLL_PUBLIC jsmntok_t * json_get_array(const char *buf, jsmntok_t *parent, const char *name)
Get the pointer to an array belonging to the parent object and named as the name variable.
Definition wsjson.c:131
WS_DLL_PUBLIC jsmntok_t * json_get_array_index(jsmntok_t *parent, int idx)
Get the pointer to idx element of an array.
Definition wsjson.c:155