mirror of
https://github.com/CrowCpp/Crow.git
synced 2024-06-07 21:10:44 +00:00
implement .keys()
This commit is contained in:
parent
4e39b23e45
commit
26c4d5ddef
@ -4698,6 +4698,24 @@ namespace crow
|
||||
return (*o)[str];
|
||||
}
|
||||
|
||||
std::vector<std::string> keys() const {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
size_t estimate_length() const
|
||||
{
|
||||
switch(t_)
|
||||
@ -4738,7 +4756,6 @@ namespace crow
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
friend void dump_internal(const wvalue& v, std::string& out);
|
||||
friend std::string dump(const wvalue& v);
|
||||
};
|
||||
|
@ -1316,6 +1316,24 @@ namespace crow
|
||||
return (*o)[str];
|
||||
}
|
||||
|
||||
std::vector<std::string> keys() const {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
size_t estimate_length() const
|
||||
{
|
||||
switch(t_)
|
||||
@ -1356,7 +1374,6 @@ namespace crow
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
friend void dump_internal(const wvalue& v, std::string& out);
|
||||
friend std::string dump(const wvalue& v);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user