...
This commit is contained in:
parent
bf7d8e987d
commit
57de9467f5
@ -72,13 +72,13 @@ namespace json {
|
|||||||
|
|
||||||
const std::vector<JSON>& JSON::asArray() const {
|
const std::vector<JSON>& JSON::asArray() const {
|
||||||
if (isArray())
|
if (isArray())
|
||||||
return static_cast<ArrayData*>(value)->data;
|
return static_cast<const ArrayData*>(value)->data;
|
||||||
throw misuse("json obj is not array");
|
throw misuse("json obj is not array");
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::map<std::string, JSON>& JSON::asDictionary() const {
|
const std::map<std::string, JSON>& JSON::asDictionary() const {
|
||||||
if (isDictionary())
|
if (isDictionary())
|
||||||
return static_cast<DictionaryData*>(value)->data;
|
return static_cast<const DictionaryData*>(value)->data;
|
||||||
throw misuse("json obj is not dictionary");
|
throw misuse("json obj is not dictionary");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,11 @@ void test_obvious(const JSON& A) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
json::JSON cba;
|
||||||
|
cba["boba"] = json::JSON("<>");
|
||||||
|
printf("%s\n", generate_str(cba["boba"].g(), print_compact).c_str());
|
||||||
|
// return 0;
|
||||||
|
|
||||||
test_obvious(parse_str_flawless("{ \"aaa\": true, \"2\":[true]}"));
|
test_obvious(parse_str_flawless("{ \"aaa\": true, \"2\":[true]}"));
|
||||||
test_obvious(parse_str_flawless("{ \"aa\": true, \"tttt\": [true, false]}"));
|
test_obvious(parse_str_flawless("{ \"aa\": true, \"tttt\": [true, false]}"));
|
||||||
test_obvious(parse_str_flawless("[[[]]]"));
|
test_obvious(parse_str_flawless("[[[]]]"));
|
||||||
|
Loading…
Reference in New Issue
Block a user