diff --git a/src/util/virjson.c b/src/util/virjson.c index f308927fa0158060c9aaf9eef4917ba216a24129..65d6521789fcee0d92e66e9122df724575e831b0 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -2049,6 +2049,10 @@ virJSONStringReformat(const char *jsonstr, } +static virJSONValuePtr +virJSONValueObjectDeflattenKeys(virJSONValuePtr json); + + static int virJSONValueObjectDeflattenWorker(const char *key, virJSONValuePtr value, @@ -2064,7 +2068,7 @@ virJSONValueObjectDeflattenWorker(const char *key, if (!strchr(key, '.')) { if (virJSONValueIsObject(value)) - newval = virJSONValueObjectDeflatten(value); + newval = virJSONValueObjectDeflattenKeys(value); else newval = virJSONValueCopy(value); @@ -2113,6 +2117,20 @@ virJSONValueObjectDeflattenWorker(const char *key, } +static virJSONValuePtr +virJSONValueObjectDeflattenKeys(virJSONValuePtr json) +{ + g_autoptr(virJSONValue) deflattened = virJSONValueNewObject(); + + if (virJSONValueObjectForeachKeyValue(json, + virJSONValueObjectDeflattenWorker, + deflattened) < 0) + return NULL; + + return g_steal_pointer(&deflattened); +} + + /** * virJSONValueObjectDeflatten: * @@ -2128,12 +2146,5 @@ virJSONValueObjectDeflattenWorker(const char *key, virJSONValuePtr virJSONValueObjectDeflatten(virJSONValuePtr json) { - g_autoptr(virJSONValue) deflattened = virJSONValueNewObject(); - - if (virJSONValueObjectForeachKeyValue(json, - virJSONValueObjectDeflattenWorker, - deflattened) < 0) - return NULL; - - return g_steal_pointer(&deflattened); + return virJSONValueObjectDeflattenKeys(json); }