aboutsummaryrefslogtreecommitdiffstats
path: root/include/crow/json.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/crow/json.h')
-rw-r--r--include/crow/json.h22
1 files changed, 8 insertions, 14 deletions
diff --git a/include/crow/json.h b/include/crow/json.h
index 3d9ed18..d8dbace 100644
--- a/include/crow/json.h
+++ b/include/crow/json.h
@@ -1333,22 +1333,16 @@ namespace crow
return (*o)[str];
}
- std::vector<std::string> keys() const {
+ std::vector<std::string> keys() const
+ {
+ if (t_ != type::Object)
+ return {};
std::vector<std::string> result;
- switch (t_) {
- case type::Null: return result;
- case type::False: return result;
- case type::True: return result;
- case type::Number: return result;
- case type::String: return result;
- case type::List: return result;
- case type::Object: {
- for (auto& kv:*o) {
- result.push_back(kv.first);
- }
- return result;
- }
+ for (auto& kv:*o)
+ {
+ result.push_back(kv.first);
}
+ return result;
}
size_t estimate_length() const