mirror of https://github.com/Icinga/icinga2.git
Implement support for deserializing JSON arrays.
This commit is contained in:
parent
3a99842f90
commit
959b7fa16a
|
@ -105,7 +105,15 @@ Value Value::FromJson(cJSON *json)
|
||||||
return Dictionary::FromJson(json);
|
return Dictionary::FromJson(json);
|
||||||
else if (json->type == cJSON_NULL)
|
else if (json->type == cJSON_NULL)
|
||||||
return Value();
|
return Value();
|
||||||
else
|
else if (json->type == cJSON_Array) {
|
||||||
|
Dictionary::Ptr dict = boost::make_shared<Dictionary>();
|
||||||
|
|
||||||
|
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."));
|
BOOST_THROW_EXCEPTION(invalid_argument("Unsupported JSON type."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue