Wireshark 4.5.0
The Wireshark network protocol analyzer
|
#include "ws_symbol_export.h"
#include <inttypes.h>
#include <stdbool.h>
#include <stdio.h>
#include <glib.h>
Go to the source code of this file.
Classes | |
struct | json_dumper |
Macros | |
#define | JSON_DUMPER_MAX_DEPTH 1100 |
#define | JSON_DUMPER_FLAGS_PRETTY_PRINT (1 << 0) /* Enable pretty printing. */ |
#define | JSON_DUMPER_DOT_TO_UNDERSCORE (1 << 1) /* Convert dots to underscores in keys */ |
#define | JSON_DUMPER_FLAGS_NO_DEBUG (1 << 17) /* Disable fatal ws_error messages on error(intended for speeding up fuzzing). */ |
Typedefs | |
typedef struct json_dumper | json_dumper |
Functions | |
WS_DLL_PUBLIC void | json_dumper_begin_object (json_dumper *dumper) |
WS_DLL_PUBLIC void | json_dumper_set_member_name (json_dumper *dumper, const char *name) |
WS_DLL_PUBLIC void | json_dumper_end_object (json_dumper *dumper) |
WS_DLL_PUBLIC void | json_dumper_begin_array (json_dumper *dumper) |
WS_DLL_PUBLIC void | json_dumper_end_array (json_dumper *dumper) |
WS_DLL_PUBLIC void | json_dumper_value_string (json_dumper *dumper, const char *value) |
WS_DLL_PUBLIC void | json_dumper_value_double (json_dumper *dumper, double value) |
WS_DLL_PUBLIC void | json_dumper_value_anyf (json_dumper *dumper, const char *format,...) G_GNUC_PRINTF(2 |
WS_DLL_PUBLIC void WS_DLL_PUBLIC void | json_dumper_value_va_list (json_dumper *dumper, const char *format, va_list ap) |
WS_DLL_PUBLIC void | json_dumper_begin_base64 (json_dumper *dumper) |
WS_DLL_PUBLIC void | json_dumper_end_base64 (json_dumper *dumper) |
WS_DLL_PUBLIC void | json_dumper_write_base64 (json_dumper *dumper, const unsigned char *data, size_t len) |
WS_DLL_PUBLIC bool | json_dumper_finish (json_dumper *dumper) |
Routines for serializing data as JSON.
Copyright 2018, Peter Wu peter.nosp@m.@lek.nosp@m.enste.nosp@m.yn.n.nosp@m.l
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
#define JSON_DUMPER_MAX_DEPTH 1100 |
Example:
json_dumper dumper = { .output_file = stdout, // or .output_string = g_string_new(NULL) .flags = JSON_DUMPER_FLAGS_PRETTY_PRINT, }; json_dumper_begin_object(&dumper); json_dumper_set_member_name(&dumper, "key"); json_dumper_value_string(&dumper, "value"); json_dumper_set_member_name(&dumper, "array"); json_dumper_begin_array(&dumper); json_dumper_value_anyf(&dumper, "true"); json_dumper_value_double(&dumper, 1.0); json_dumper_begin_base64(&dumper); json_dumper_write_base64(&dumper, (const unsigned char *)"abcd", 4); json_dumper_write_base64(&dumper, (const unsigned char *)"1234", 4); json_dumper_end_base64(&dumper); json_dumper_begin_object(&dumper); json_dumper_end_object(&dumper); json_dumper_begin_array(&dumper); json_dumper_end_array(&dumper); json_dumper_end_array(&dumper); json_dumper_end_object(&dumper); json_dumper_finish(&dumper); Maximum object/array nesting depth.
WS_DLL_PUBLIC bool json_dumper_finish | ( | json_dumper * | dumper | ) |
Finishes dumping data. Returns true if everything is okay and false if something went wrong (open/close mismatch, missing values, etc.).
WS_DLL_PUBLIC void json_dumper_value_anyf | ( | json_dumper * | dumper, |
const char * | format, | ||
... | |||
) |
Dump number, "true", "false" or "null" values.
WS_DLL_PUBLIC void WS_DLL_PUBLIC void json_dumper_value_va_list | ( | json_dumper * | dumper, |
const char * | format, | ||
va_list | ap | ||
) |
Dump literal values (like json_dumper_value_anyf), but taking a va_list as parameter. String values MUST be properly quoted by the caller, no escaping occurs. Do not use with untrusted data.