From 959b7fa16aa68cd8d510b1bfdfa6c7c90c052170 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Thu, 28 Feb 2013 14:06:30 +0100 Subject: [PATCH] Implement support for deserializing JSON arrays. --- lib/base/value.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/base/value.cpp b/lib/base/value.cpp index d4a2486ae..6beda0dc9 100644 --- a/lib/base/value.cpp +++ b/lib/base/value.cpp @@ -105,7 +105,15 @@ Value Value::FromJson(cJSON *json) return Dictionary::FromJson(json); else if (json->type == cJSON_NULL) return Value(); - else + else if (json->type == cJSON_Array) { + Dictionary::Ptr dict = boost::make_shared(); + + for (cJSON *i = json->child; i != NULL; i = i->next) { + dict->Add(Value::FromJson(i)); + } + + return dict; + } else BOOST_THROW_EXCEPTION(invalid_argument("Unsupported JSON type.")); } -- 2.40.0