diff --git a/models/relay_dbo.cc b/models/relay_dbo.cc index eabbc09..363a72c 100644 --- a/models/relay_dbo.cc +++ b/models/relay_dbo.cc @@ -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; } diff --git a/models/schedule_dbo.cc b/models/schedule_dbo.cc index eb4254c..b3e7ca9 100644 --- a/models/schedule_dbo.cc +++ b/models/schedule_dbo.cc @@ -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; }