X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/77bec1261eedf1f3afaa9b03c14c8a8a08b11164..d7a3039c2a4bd26d05f08ee3140b8dfaecd68f02:/nominatim/utils/json_writer.py?ds=inline diff --git a/nominatim/utils/json_writer.py b/nominatim/utils/json_writer.py index e2e5b9e6..bb642233 100644 --- a/nominatim/utils/json_writer.py +++ b/nominatim/utils/json_writer.py @@ -101,6 +101,11 @@ class JsonWriter: return self.raw(json.dumps(value, ensure_ascii=False)) + def float(self, value: float, precision: int) -> 'JsonWriter': + """ Write out a float value with the given precision. + """ + return self.raw(f"{value:0.{precision}f}") + def next(self) -> 'JsonWriter': """ Write out a delimiter comma between JSON object or array elements. """