From 9d158fcf2d0929a2dfdfc2a524ec8a31f8e5c9d1 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sat, 5 May 2012 21:16:03 +0200 Subject: [PATCH] vjson: Add simple accessors for getting arrays and dicts --- ext/vjson/json.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ext/vjson/json.h b/ext/vjson/json.h index 08c4ba8b7a..5c56ee10cf 100644 --- a/ext/vjson/json.h +++ b/ext/vjson/json.h @@ -41,6 +41,12 @@ struct json_value int numSiblings() const; // num siblings *after* this one only const json_value *get(const char *child_name) const; const json_value *get(const char *child_name, json_type type) const; + const json_value *getArray(const char *child_name) const { + return get(child_name, JSON_ARRAY); + } + const json_value *getDict(const char *child_name) const { + return get(child_name, JSON_OBJECT); + } const char *getString(const char *child_name) const; const char *getString(const char *child_name, const char *default_value) const; bool getStringVector(std::vector *vec) const; @@ -50,7 +56,7 @@ struct json_value int getInt(const char *child_name, int default_value) const; bool getBool(const char *child_name) const; bool getBool(const char *child_name, bool default_value) const; - + private: DISALLOW_COPY_AND_ASSIGN(json_value); };