Commit ee4d4625 authored by Mathieu Giraud's avatar Mathieu Giraud

core/output.cpp: get(), do not create fields when they do not exists

parent ff16f107
......@@ -13,14 +13,23 @@ string getout(json v)
string Output::get(string key)
{
if (!j.count(key)) return NULL_VAL ;
return getout(j[key]);
}
string Output::get(string key, string subkey)
{
if (!j.count(key)) return NULL_VAL ;
if (!j[key].count(subkey)) return NULL_VAL ;
return getout(j[key][subkey]);
}
string Output::get(string key, string subkey, string subsubkey)
{
if (!j.count(key)) return NULL_VAL ;
if (!j[key].count(subkey)) return NULL_VAL ;
if (!j[key][subkey].count(subsubkey)) return NULL_VAL ;
return getout(j[key][subkey][subsubkey]);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment