mirror of
https://github.com/CrowCpp/Crow.git
synced 2024-06-07 21:10:44 +00:00
Simplify json.keys()
This commit is contained in:
parent
6da6579ce9
commit
9c26e1ebde
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user