Create and print JSON output.
More...
#include <json.h>
|
ref | operator[] (const char *keystr) |
| Return reference to element of top level object.
|
|
ref | operator[] (const std::string &keystr) |
| Return reference to element of top level object (std::string variant).
|
|
void | operator+= (std::initializer_list< initlist_key_value_pair > ilist) |
| Braced-init-list support for top level object.
|
|
void | enable (bool yes=true) |
| Enable/disable JSON output.
|
|
bool | is_enabled () const |
| Return true if enabled.
|
|
void | set_verbose (bool yes=true) |
| Enable/disable extra string output for safe integers also.
|
|
bool | has_uint128_output () const |
| Return true if any 128-bit value has been output.
|
|
void | print (FILE *f, const print_options &options) const |
| Print JSON tree to a file.
|
|
|
static bool | is_safe_uint (unsigned long long value) |
| Return true if value is a safe JSON integer.
|
|
static std::string | str2key (const char *str) |
| Replace space and non-alphanumerics with '_', upper to lower case.
|
|
static std::string | str2key (const std::string &str) |
| Replace space and non-alphanumerics with '_', upper to lower case (std::string variant).
|
|
|
static void | print_json (FILE *f, bool pretty, bool sorted, const node *p, int level) |
|
static void | print_yaml (FILE *f, bool pretty, bool sorted, const node *p, int level_o, int level_a, bool cont) |
|
static void | print_flat (FILE *f, const char *assign, bool sorted, const node *p, std::string &path) |
|
Create and print JSON output.
Definition at line 23 of file json.h.
◆ node_path
◆ node_type
Enumerator |
---|
nt_unset | |
nt_object | |
nt_array | |
nt_bool | |
nt_int | |
nt_uint | |
nt_uint128 | |
nt_string | |
Definition at line 39 of file json.h.
◆ enable()
void json::enable |
( |
bool |
yes = true | ) |
|
|
inline |
Enable/disable JSON output.
Definition at line 183 of file json.h.
◆ find_or_create_node()
◆ has_uint128_output()
bool json::has_uint128_output |
( |
| ) |
const |
|
inline |
Return true if any 128-bit value has been output.
Definition at line 195 of file json.h.
◆ is_enabled()
bool json::is_enabled |
( |
| ) |
const |
|
inline |
Return true if enabled.
Definition at line 187 of file json.h.
◆ is_safe_uint()
static bool json::is_safe_uint |
( |
unsigned long long |
value | ) |
|
|
inlinestatic |
Return true if value is a safe JSON integer.
Same as Number.isSafeInteger(value) in JavaScript.
Definition at line 28 of file json.h.
◆ operator+=()
Braced-init-list support for top level object.
Definition at line 179 of file json.h.
◆ operator[]() [1/2]
ref json::operator[] |
( |
const char * |
keystr | ) |
|
|
inline |
Return reference to element of top level object.
Definition at line 171 of file json.h.
◆ operator[]() [2/2]
ref json::operator[] |
( |
const std::string & |
keystr | ) |
|
|
inline |
Return reference to element of top level object (std::string variant).
Definition at line 175 of file json.h.
◆ print()
void json::print |
( |
FILE * |
f, |
|
|
const print_options & |
options |
|
) |
| const |
Print JSON tree to a file.
Definition at line 710 of file json.cpp.
◆ print_flat()
void json::print_flat |
( |
FILE * |
f, |
|
|
const char * |
assign, |
|
|
bool |
sorted, |
|
|
const node * |
p, |
|
|
std::string & |
path |
|
) |
| |
|
staticprivate |
◆ print_json()
void json::print_json |
( |
FILE * |
f, |
|
|
bool |
pretty, |
|
|
bool |
sorted, |
|
|
const node * |
p, |
|
|
int |
level |
|
) |
| |
|
staticprivate |
◆ print_yaml()
void json::print_yaml |
( |
FILE * |
f, |
|
|
bool |
pretty, |
|
|
bool |
sorted, |
|
|
const node * |
p, |
|
|
int |
level_o, |
|
|
int |
level_a, |
|
|
bool |
cont |
|
) |
| |
|
staticprivate |
◆ set_bool()
void json::set_bool |
( |
const node_path & |
path, |
|
|
bool |
value |
|
) |
| |
|
private |
◆ set_cstring()
void json::set_cstring |
( |
const node_path & |
path, |
|
|
const char * |
value |
|
) |
| |
|
private |
◆ set_initlist_value()
◆ set_int64()
void json::set_int64 |
( |
const node_path & |
path, |
|
|
int64_t |
value |
|
) |
| |
|
private |
◆ set_string()
void json::set_string |
( |
const node_path & |
path, |
|
|
const std::string & |
value |
|
) |
| |
|
private |
◆ set_uint128()
void json::set_uint128 |
( |
const node_path & |
path, |
|
|
uint64_t |
value_hi, |
|
|
uint64_t |
value_lo |
|
) |
| |
|
private |
◆ set_uint64()
void json::set_uint64 |
( |
const node_path & |
path, |
|
|
uint64_t |
value |
|
) |
| |
|
private |
◆ set_verbose()
void json::set_verbose |
( |
bool |
yes = true | ) |
|
|
inline |
Enable/disable extra string output for safe integers also.
Definition at line 191 of file json.h.
◆ str2key() [1/2]
std::string json::str2key |
( |
const char * |
str | ) |
|
|
static |
Replace space and non-alphanumerics with '_', upper to lower case.
Definition at line 41 of file json.cpp.
◆ str2key() [2/2]
static std::string json::str2key |
( |
const std::string & |
str | ) |
|
|
inlinestatic |
Replace space and non-alphanumerics with '_', upper to lower case (std::string variant).
Definition at line 36 of file json.h.
◆ m_enabled
bool json::m_enabled = false |
|
private |
◆ m_root_node
◆ m_uint128_output
bool json::m_uint128_output = false |
|
private |
◆ m_verbose
bool json::m_verbose = false |
|
private |
The documentation for this class was generated from the following files: