unified namespace to read and write JSON More...
Classes | |
struct | object |
storge container for a JSON object More... | |
Typedefs | |
template<typename T> | |
using | is_string_like = std::is_same<std::decay_t<T>, std::string> |
template<typename T> | |
using | is_json_list_like = std::conjunction<aurostd::is_list_like<T>, std::negation<is_string_like<T>>> |
template<typename T> | |
using | enable_list_like = std::enable_if_t<is_json_list_like<T>::value, bool> |
template<typename T> | |
using | enable_dict_like = std::enable_if_t<aurostd::is_dict_like_v<T>, bool> |
template<typename T> | |
using | enable_serializable = std::enable_if_t<std::is_base_of_v<JsonSerializable<T>, T>, bool> |
template<typename T> | |
using | enable_arithmetic = std::enable_if_t<std::is_arithmetic_v<T>, bool> |
typedef std::vector< object > | List |
shortcut for JSON::object_types::LIST | |
typedef std::map< std::string, object > | Dictionary |
shortcut for JSON::object_types::DICTIONARY | |
Enumerations | |
enum class | object_types { DICTIONARY , LIST , STRING , FLOAT , INTEGER , T , F , NONE } |
Functions | |
std::string | unescape_unicode (const std::string &raw, size_t &pos) |
unescape JSON unicode instances | |
std::string | escape (const std::string &raw, bool unicode=true) |
prepare string for JSON output with or without Unicode escapes | |
std::string | char32_to_string (char32_t cp) |
convert a unicode codepoint to a series of utf8 chars | |
std::string | char_escape (char16_t c) |
escape characters to JSON | |
object | loadFile (const std::string &file_path) |
create a JSON::object from file | |
object | loadString (const std::string &content) |
create a JSON::object from raw string | |
void | saveFile (const object &root, const std::string &file_path, compression_type ct=compression_type::None, bool escape_unicode=true) |
save JSON::object to file | |
std::string | toString (const object &root, bool escape_unicode=false) |
convert JSON::object to string | |
std::pair< size_t, size_t > | find_string (const std::string &raw_content, std::pair< size_t, size_t > border={0, 0}) |
find the border of a JSON string | |
std::pair< size_t, size_t > | find_bracket (const std::string &raw_content, char kind_open, std::pair< size_t, size_t > border={0, 0}) |
find the border of an encapsulated by brackets | |
std::pair< size_t, size_t > | find_strip (const std::string &raw_content, std::pair< size_t, size_t > border={0, 0}) |
strip whitespaces | |
object | parse (const std::string &raw_content, std::pair< size_t, size_t > border={0, 0}) |
parse a raw JSON string | |
std::string | parse_string (const std::string &raw_content, std::pair< size_t, size_t > border={0, 0}) |
parse JSON string | |
unified namespace to read and write JSON
Load data example
Save data example
using aurostd::JSON::is_string_like = std::is_same<std::decay_t<T>, std::string> |
Definition at line 30 of file aurostd_xparser_json.h.
using aurostd::JSON::is_json_list_like = std::conjunction<aurostd::is_list_like<T>, std::negation<is_string_like<T>>> |
Definition at line 31 of file aurostd_xparser_json.h.
using aurostd::JSON::enable_list_like = std::enable_if_t<is_json_list_like<T>::value, bool> |
Definition at line 32 of file aurostd_xparser_json.h.
using aurostd::JSON::enable_dict_like = std::enable_if_t<aurostd::is_dict_like_v<T>, bool> |
Definition at line 33 of file aurostd_xparser_json.h.
using aurostd::JSON::enable_serializable = std::enable_if_t<std::is_base_of_v<JsonSerializable<T>, T>, bool> |
Definition at line 34 of file aurostd_xparser_json.h.
using aurostd::JSON::enable_arithmetic = std::enable_if_t<std::is_arithmetic_v<T>, bool> |
Definition at line 35 of file aurostd_xparser_json.h.
typedef std::vector<object> aurostd::JSON::List |
shortcut for JSON::object_types::LIST
Definition at line 37 of file aurostd_xparser_json.h.
typedef std::map<std::string, object> aurostd::JSON::Dictionary |
shortcut for JSON::object_types::DICTIONARY
Definition at line 38 of file aurostd_xparser_json.h.
|
strong |
Enumerator | |
---|---|
DICTIONARY | |
LIST | |
STRING | |
FLOAT | |
INTEGER | |
T | |
F | |
NONE |
Definition at line 40 of file aurostd_xparser_json.h.
std::string aurostd::JSON::unescape_unicode | ( | const std::string & | raw, |
size_t & | pos ) |
unescape JSON unicode instances
raw | raw content string |
pos | starting position of the hex representation |
Definition at line 840 of file aurostd_xparser_json.cpp.
std::string aurostd::JSON::escape | ( | const std::string & | raw, |
bool | unicode = true ) |
prepare string for JSON output with or without Unicode escapes
raw | string to escape |
unicode | if true escape Unicode characters (default true) |
Definition at line 776 of file aurostd_xparser_json.cpp.
std::string aurostd::JSON::char32_to_string | ( | char32_t | cp | ) |
convert a unicode codepoint to a series of utf8 chars
cp | 32bit codepoint |
Definition at line 808 of file aurostd_xparser_json.cpp.
std::string aurostd::JSON::char_escape | ( | char16_t | c | ) |
escape characters to JSON
Definition at line 756 of file aurostd_xparser_json.cpp.
JSON::object aurostd::JSON::loadFile | ( | const std::string & | file_path | ) |
create a JSON::object from file
file_path | file path to load from |
Definition at line 1106 of file aurostd_xparser_json.cpp.
JSON::object aurostd::JSON::loadString | ( | const std::string & | content | ) |
create a JSON::object from raw string
content | raw JSON content |
Definition at line 1114 of file aurostd_xparser_json.cpp.
void aurostd::JSON::saveFile | ( | const object & | root, |
const std::string & | file_path, | ||
compression_type | ct = compression_type::None, | ||
bool | escape_unicode = true ) |
save JSON::object to file
root | JSON::object to save |
file_path | file path to save to |
escape_unicode | if true escape Unicode characters |
Definition at line 1130 of file aurostd_xparser_json.cpp.
convert JSON::object to string
root | JSON::object to convert |
escape_unicode | if true escape Unicode characters |
Definition at line 1122 of file aurostd_xparser_json.cpp.
std::pair< size_t, size_t > aurostd::JSON::find_string | ( | const std::string & | raw_content, |
std::pair< size_t, size_t > | border = {0, 0} ) |
find the border of a JSON string
raw_content | full json string |
border | working border |
Definition at line 884 of file aurostd_xparser_json.cpp.
std::pair< size_t, size_t > aurostd::JSON::find_bracket | ( | const std::string & | raw_content, |
char | kind_open, | ||
std::pair< size_t, size_t > | border = {0, 0} ) |
find the border of an encapsulated by brackets
raw_content | full json string |
kind_open | type of bracket [ { ( |
border | working border |
Definition at line 920 of file aurostd_xparser_json.cpp.
std::pair< size_t, size_t > aurostd::JSON::find_strip | ( | const std::string & | raw_content, |
std::pair< size_t, size_t > | border = {0, 0} ) |
strip whitespaces
raw_content | full json string |
border | working border |
Definition at line 869 of file aurostd_xparser_json.cpp.
JSON::object aurostd::JSON::parse | ( | const std::string & | raw_content, |
std::pair< size_t, size_t > | border = {0, 0} ) |
parse a raw JSON string
raw_content | full json string |
border | working border |
Definition at line 971 of file aurostd_xparser_json.cpp.
std::string aurostd::JSON::parse_string | ( | const std::string & | raw_content, |
std::pair< size_t, size_t > | border = {0, 0} ) |
parse JSON string
raw_content | full json string |
border | string borders |
Definition at line 696 of file aurostd_xparser_json.cpp.