| Wireshark 4.7.0 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
wsjson.h
Go to the documentation of this file.
1
14#ifndef __WSJSON_H__
15#define __WSJSON_H__
16
17#include "ws_symbol_export.h"
18
19#include <inttypes.h>
20#include <stdbool.h>
21
22#include "jsmn.h"
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
39WS_DLL_PUBLIC bool json_validate(const uint8_t *buf, const size_t len);
40
53WS_DLL_PUBLIC int json_parse(const char *buf, jsmntok_t *tokens, unsigned int max_tokens);
54
69WS_DLL_PUBLIC int json_parse_len(const char *buf, size_t len, jsmntok_t *tokens, unsigned int max_tokens);
70
79WS_DLL_PUBLIC jsmntok_t *json_get_object(const char *buf, jsmntok_t *parent, const char *name);
80
89WS_DLL_PUBLIC jsmntok_t *json_get_array(const char *buf, jsmntok_t *parent, const char *name);
90
97WS_DLL_PUBLIC int json_get_array_len(jsmntok_t *array);
98
110WS_DLL_PUBLIC jsmntok_t *json_get_array_index(jsmntok_t *parent, int idx);
111
131WS_DLL_PUBLIC jsmntok_t *json_get_next_object(jsmntok_t *cur);
132
143WS_DLL_PUBLIC char *json_get_string(char *buf, jsmntok_t *parent, const char *name);
144
156WS_DLL_PUBLIC bool json_get_double(char *buf, jsmntok_t *parent, const char *name, double *val);
157
169WS_DLL_PUBLIC bool json_get_int(char *buf, jsmntok_t *parent, const char *name, int64_t *val);
170
182WS_DLL_PUBLIC bool json_get_boolean(char *buf, jsmntok_t *parent, const char *name, bool *val);
183
190WS_DLL_PUBLIC bool json_decode_string_inplace(char *text);
191
192#ifdef __cplusplus
193}
194#endif
195
196#endif
197
198/*
199 * Editor modelines - https://www.wireshark.org/tools/modelines.html
200 *
201 * Local variables:
202 * c-basic-offset: 4
203 * tab-width: 8
204 * indent-tabs-mode: nil
205 * End:
206 *
207 * vi: set shiftwidth=4 tabstop=8 expandtab:
208 * :indentSize=4:tabSize=8:noTabs=true:
209 */
jsmn.h
jsmntok_t
Definition jsmn.h:69
json_validate
WS_DLL_PUBLIC bool json_validate(const uint8_t *buf, const size_t len)
Check if a buffer is valid JSON.
Definition wsjson.c:26
json_get_double
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:189
json_get_string
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:169
json_parse
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:87
json_decode_string_inplace
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:269
json_get_array_len
WS_DLL_PUBLIC int json_get_array_len(jsmntok_t *array)
Get the number of elements of an array.
Definition wsjson.c:149
json_get_int
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
json_parse_len
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:96
json_get_object
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:115
json_get_boolean
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:231
json_get_next_object
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:104
json_get_array
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:132
json_get_array_index
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:156