This commit is contained in:
Андреев Григорий 2024-08-16 00:01:30 +03:00
parent bf7d8e987d
commit 57de9467f5
2 changed files with 7 additions and 2 deletions

View File

@ -72,13 +72,13 @@ namespace json {
const std::vector<JSON>& JSON::asArray() const {
if (isArray())
return static_cast<ArrayData*>(value)->data;
return static_cast<const ArrayData*>(value)->data;
throw misuse("json obj is not array");
}
const std::map<std::string, JSON>& JSON::asDictionary() const {
if (isDictionary())
return static_cast<DictionaryData*>(value)->data;
return static_cast<const DictionaryData*>(value)->data;
throw misuse("json obj is not dictionary");
}

View File

@ -35,6 +35,11 @@ void test_obvious(const JSON& A) {
}
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("{ \"aa\": true, \"tttt\": [true, false]}"));
test_obvious(parse_str_flawless("[[[]]]"));