|
Wireshark 4.7.0
The Wireshark network protocol analyzer
|
Go to the source code of this file.
Functions | |
| WS_DLL_PUBLIC bool | json_validate (const uint8_t *buf, const size_t len) |
| Check if a buffer is valid JSON. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| WS_DLL_PUBLIC int | json_get_array_len (jsmntok_t *array) |
| Get the number of elements of an array. | |
| WS_DLL_PUBLIC jsmntok_t * | json_get_array_index (jsmntok_t *parent, int idx) |
| Get the pointer to idx element of an array. | |
| 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. | |
| 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 variable. | |
| 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. | |
| 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. | |
| 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. | |
| WS_DLL_PUBLIC bool | json_decode_string_inplace (char *text) |
| Decode the contents of a JSON string value by overwriting the input data. | |
JSON parsing functions.
Copyright 2016, Dario Lombardo
Wireshark - Network traffic analyzer By Gerald Combs geral.nosp@m.d@wi.nosp@m.resha.nosp@m.rk.o.nosp@m.rg Copyright 1998 Gerald Combs
SPDX-License-Identifier: GPL-2.0-or-later
| WS_DLL_PUBLIC bool json_decode_string_inplace | ( | char * | text | ) |
Decode the contents of a JSON string value by overwriting the input data.
| text | - JSON string to decode. |
| 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.
| buf | - A buffer containing JSON, not necessarily null-terminated. |
| parent | - JSON object to search within for the name. |
| name | - The name to search the parent object for. |
name within the parent object, or NULL if not found. Get the pointer to idx element of an array.
json_get_next_object.| parent | - JSON array. |
| idx | - index of element. |
parent array's element at position idx or NULL if not found. | WS_DLL_PUBLIC int json_get_array_len | ( | jsmntok_t * | array | ) |
Get the number of elements of an array.
| array | - JSON array. |
| 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.
| buf | - A buffer containing JSON, not necessarily null-terminated. |
| parent | - JSON object to search within for the name. |
| name | - The name to search the parent object for. |
| val | - Location to store the retrieved value. |
| 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.
| buf | - A buffer containing JSON, not necessarily null-terminated. |
| parent | - JSON object to search within for the name. |
| name | - The name to search the parent object for. |
| val | - Location to store the retrieved value. |
| 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.
| buf | - A buffer containing JSON, not necessarily null-terminated. |
| parent | - JSON object to search within for the name. |
| name | - The name to search the parent object for. |
| val | - Location to store the retrieved value. |
Get the pointer to the next JSON element which is a sibling of cur.
This is used for efficiently iterating over elements of a JSON array. For example:
| cur | - JSON array element. |
| 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.
| buf | - A buffer containing JSON, not necessarily null-terminated. |
| parent | - JSON object to search within for the name. |
| name | - The name to search the parent object for. |
name within the parent object, or NULL if not found. | 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 variable.
| buf | - A buffer containing JSON, not necessarily null-terminated. |
| parent | - JSON object to search within for the name. |
| name | - The name to search the parent object for. |
name variable or NULL if not found.| 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.
| buf | - A null-terminated string containing JSON. |
| tokens | - An array for storing the parsed tokens. Can be NULL, to validate only. |
| max_tokens | - The length of tokens. Ignored if tokens is NULL. |
tokens set to NULL to determine the number of tokens necessary. | 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.
| buf | - A buffer containing JSON, not necessarily null-terminated. |
| len | - The length of the JSON data in the buffer. |
| tokens | - An array for storing the parsed tokens. Can be NULL, to validate only. |
| max_tokens | - The length of tokens. Ignored if tokens is NULL. |
tokens set to NULL to determine the number of tokens necessary. | WS_DLL_PUBLIC bool json_validate | ( | const uint8_t * | buf, |
| const size_t | len | ||
| ) |
Check if a buffer is valid JSON.
| buf | - A buffer containing JSON. |
| len | - The length of the JSON data in the buffer. |