diff --git a/src/services/variorum/Variorum.cpp b/src/services/variorum/Variorum.cpp index 1f807a9d1..468d1a071 100644 --- a/src/services/variorum/Variorum.cpp +++ b/src/services/variorum/Variorum.cpp @@ -46,21 +46,24 @@ std::tuple measure(const std::string& name) return std::make_tuple(false, val); } - //Extract and print values from JSON object + //Extract the values from JSON object energy_obj = json_loads(s, JSON_DECODE_ANY, NULL); void *iter = json_object_iter(energy_obj); while (iter) { - node_obj = json_object_iter_value(iter); - if (node_obj == NULL) - { - printf("JSON object not found"); - exit(0); - } + node_obj = json_object_iter_value(iter); + if (node_obj == NULL) + { + printf("JSON object not found."); + exit(0); + } /* The following should return NULL after the first call per our object. */ iter = json_object_iter_next(energy_obj, iter); - } + + } + + energy_joules = json_integer_value(json_object_get(node_obj, name.c_str())); //Deallocate the string free(s);