| 174 | } |
| 175 | |
| 176 | TimeTable GetTimeTableFromJson(json_t * obj) |
| 177 | { |
| 178 | json_t * arr = base::GetJSONOptionalField(obj, "timetable"); |
| 179 | if (!arr) |
| 180 | return TimeTable{}; |
| 181 | |
| 182 | CHECK(json_is_array(arr), ()); |
| 183 | |
| 184 | TimeTable timetable; |
| 185 | |
| 186 | for (size_t i = 0; i < json_array_size(arr); ++i) |
| 187 | { |
| 188 | json_t * item = json_array_get(arr, i); |
| 189 | CHECK(json_is_object(item), ()); |
| 190 | |
| 191 | TransitId lineId; |
| 192 | FromJSONObject(item, "line_id", lineId); |
| 193 | |
| 194 | std::vector<TimeInterval> timeIntervals; |
| 195 | |
| 196 | auto const & rawValues = GetVectorFromJson<uint64_t>(item, "intervals"); |
| 197 | timeIntervals.reserve(rawValues.size()); |
| 198 | for (auto const & rawValue : rawValues) |
| 199 | timeIntervals.push_back(TimeInterval(rawValue)); |
| 200 | |
| 201 | timetable[lineId] = timeIntervals; |
| 202 | } |
| 203 | |
| 204 | return timetable; |
| 205 | } |
| 206 | |
| 207 | Translations GetTranslationsFromJson(json_t * obj, std::string const & field) |
| 208 | { |
no test coverage detected