fix: add tags array to json even when empty

This commit is contained in:
Tobias Reisinger 2020-04-28 21:51:47 +02:00
parent 42c168e627
commit a234a79828
2 changed files with 4 additions and 5 deletions

View file

@ -173,10 +173,10 @@ relay_dbo::to_json()
relay_json["active_schedule"] = this->active_schedule->to_json();
relay_json["schedules"] = schedules_json;
Json::Value tags_json(Json::arrayValue);
int *tags_ids = junction_tag_dbo::get_tags_for_relay_id(this->id);
if(tags_ids != nullptr)
{
Json::Value tags_json(Json::arrayValue);
int tags_count;
for(tags_count = 0; tags_ids[tags_count] != 0; ++tags_count);
@ -188,8 +188,8 @@ relay_dbo::to_json()
tags[i] = tag_dbo::get_tag(tags_ids[i]);
tags_json[i] = tags[i];
}
relay_json["tags"] = tags_json;
}
relay_json["tags"] = tags_json;
return relay_json;
}

View file

@ -153,11 +153,10 @@ schedule_dbo::to_json()
schedule_json["id"] = id_str;
schedule_json["periods"] = this->periods->to_json();
Json::Value tags_json(Json::arrayValue);
int *tags_ids = junction_tag_dbo::get_tags_for_schedule_id(this->id);
if(tags_ids != nullptr)
{
Json::Value tags_json(Json::arrayValue);
int tags_count;
for(tags_count = 0; tags_ids[tags_count] != 0; ++tags_count);
@ -168,8 +167,8 @@ schedule_dbo::to_json()
tags[i] = tag_dbo::get_tag(tags_ids[i]);
tags_json[i] = tags[i];
}
schedule_json["tags"] = tags_json;
}
schedule_json["tags"] = tags_json;
return schedule_json;
}