6#include <unordered_map>
24 json(std::string str);
25 json(
const char *str);
26 json(
const std::vector<json>& arr);
27 json(
const std::unordered_map<std::string, json>& obj);
43 static json parse(
const std::string& str);
44 static json load(
const std::filesystem::path& path);
45 std::string
to_string(
int indent = 0,
bool sort_keys =
false)
const;
51 json&
at(
const std::string& key);
52 const json&
at(
const std::string& key)
const;
58 const json&
at(std::size_t pos)
const;
71 const std::vector<json>&
array_ref()
const;
72 std::unordered_map<std::string, json>&
object_ref();
73 const std::unordered_map<std::string, json>&
object_ref()
const;
84 bool is_double_{
false};
91 std::unordered_map<std::string, json> *
object_;
97static_assert(
sizeof(int64_t) ==
sizeof(
double));
json & operator[](const std::string &key)
Definition: json.cpp:436
json & at(const std::string &key)
Definition: json.cpp:434
std::string to_string(int indent=0, bool sort_keys=false) const
Definition: json.cpp:539
~json()
Definition: json.cpp:373
std::vector< json > & array_ref()
Definition: json.cpp:585
int64_t i64_
Definition: json.h:88
std::unordered_map< std::string, json > * object_
Definition: json.h:91
json(value_type type=null)
Definition: json.cpp:221
void reset()
Definition: json.cpp:393
bool is_string() const
Definition: json.cpp:602
value_type
Definition: json.h:16
@ array
Definition: json.h:16
@ boolean
Definition: json.h:16
@ string
Definition: json.h:16
@ object
Definition: json.h:16
@ null
Definition: json.h:16
@ number
Definition: json.h:16
json & operator=(const json &other)
Definition: json.cpp:313
std::string & string_ref()
Definition: json.cpp:578
bool is_boolean() const
Definition: json.cpp:600
bool operator==(const json &other) const
Definition: json.cpp:462
double & double_ref()
Definition: json.cpp:564
bool operator!=(const json &other) const
Definition: json.cpp:477
double double_
Definition: json.h:87
std::unordered_map< std::string, json > & object_ref()
Definition: json.cpp:592
bool is_array() const
Definition: json.cpp:603
std::string * string_
Definition: json.h:89
std::vector< json > * array_
Definition: json.h:90
static json parse(const std::string &str)
Definition: json.cpp:412
value_type type() const
Definition: json.cpp:375
bool bool_
Definition: json.h:86
bool is_null() const
Definition: json.cpp:599
static json load(const std::filesystem::path &path)
Definition: json.cpp:421
bool is_number() const
Definition: json.cpp:601
bool is_object() const
Definition: json.cpp:604
bool & bool_ref()
Definition: json.cpp:557
void clear()
Definition: json.cpp:377
int64_t & i64_ref()
Definition: json.cpp:571
Definition: algorithm.h:10