Merge pull request #174 from taylorking/master

implement .keys()
This commit is contained in:
Jaeseung Ha 2017-09-17 19:18:07 +09:00 committed by GitHub
commit a92c305acb
2 changed files with 18 additions and 46 deletions

View File

@ -9660,48 +9660,3 @@ namespace crow
#pragma once

View File

@ -1333,6 +1333,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_)
@ -1373,7 +1391,6 @@ namespace crow
return 1;
}
friend void dump_internal(const wvalue& v, std::string& out);
friend std::string dump(const wvalue& v);
};