+ else if (args != nullptr &&
+ (json_object_object_get_ex(args, "id", &json_name)))
+ {
+ if (json_object_get_type(json_name) == json_type_string) // id is set before and check if it's an array
+ {
+ ans = get_id_value(json_object_get_int(json_name));
+ }
+ else if(json_object_get_type(json_name) == json_type_array)
+ {
+ ans = json_object_new_array();
+ for (int i = 0 ; i < json_object_array_length(json_name); i++)
+ {
+ json_object *sub_ans = nullptr;
+ json_object *x = json_object_array_get_idx(json_name, i);
+ sub_ans = get_id_value(json_object_get_int(x));
+ if(!sub_ans)
+ rc = -1;
+ else {
+ struct json_object *jobj = json_object_new_object();
+ struct json_object *jid = json_object_new_string(json_object_get_string(x));
+ json_object_object_add(jobj, "id", jid);
+ json_object_object_add(jobj, "data", sub_ans);
+ json_object_array_add(ans, jobj);
+ }
+ }
+ }
+ else
+ rc = -1;
+ if (!ans)
+ rc = -1;
+ }