aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaeseung Ha <ipknhama@gmail.com>2017-09-17 19:18:07 +0900
committerGitHub <noreply@github.com>2017-09-17 19:18:07 +0900
commita92c305acb2be3f6530ea157084e5004500dd244 (patch)
tree0ad063878c09eec987d1d8054b66d11fd629ce30
parent414809c742521926ca08fbd355b92f3ae877064f (diff)
parentd8c4a671760fda8e83279b9383108f0951367fb6 (diff)
downloadcrow-a92c305acb2be3f6530ea157084e5004500dd244.tar.gz
crow-a92c305acb2be3f6530ea157084e5004500dd244.zip
Merge pull request #174 from taylorking/master
implement .keys()
-rw-r--r--amalgamate/crow_all.h45
-rw-r--r--include/crow/json.h19
2 files changed, 18 insertions, 46 deletions
diff --git a/amalgamate/crow_all.h b/amalgamate/crow_all.h
index 77fb663..0c88e5d 100644
--- a/amalgamate/crow_all.h
+++ b/amalgamate/crow_all.h
@@ -9660,48 +9660,3 @@ namespace crow
#pragma once
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/include/crow/json.h b/include/crow/json.h
index e2d116c..3d9ed18 100644
--- a/include/crow/json.h
+++ b/include/crow/json.h
@@ -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);
};