X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/30cef4d5fdfd804616506b28d5caad8d2b2385c4..78c19bc006d5957f183968d086226be4b2b65fe3:/nominatim/api/v1/format.py?ds=inline diff --git a/nominatim/api/v1/format.py b/nominatim/api/v1/format.py index 2442bb76..53156fdd 100644 --- a/nominatim/api/v1/format.py +++ b/nominatim/api/v1/format.py @@ -9,6 +9,7 @@ Output formatters for API version v1. """ from typing import List, Dict, Mapping, Any import collections +import datetime as dt import nominatim.api as napi from nominatim.api.result_formatting import FormatDispatcher @@ -140,7 +141,7 @@ def _format_details_json(result: napi.DetailedResult, options: Mapping[str, Any] if result.address_rows is not None: _add_address_rows(out, 'address', result.address_rows, locales) - if result.linked_rows is not None: + if result.linked_rows: _add_address_rows(out, 'linked_places', result.linked_rows, locales) if result.name_keywords is not None or result.address_keywords is not None: @@ -244,7 +245,10 @@ def _format_raw_data_json(results: RawDataList, _: Mapping[str, Any]) -> str: for res in results: out.start_object() for k, v in res.items(): - out.keyval(k, v) + if isinstance(v, dt.datetime): + out.keyval(k, v.isoformat(sep= ' ', timespec='seconds')) + else: + out.keyval(k, v) out.end_object().next() out.end_array()