From 3cc335ee2cee2ae2a716d11e1d161da3dc978824 Mon Sep 17 00:00:00 2001 From: Mary Bucknell Date: Mon, 14 Oct 2019 16:54:52 -0500 Subject: [PATCH] Added serialization for Decimal. The postgres provider converts number field to decimal.Decimal. (#274) --- pygeoapi/util.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pygeoapi/util.py b/pygeoapi/util.py index 8270687..fe37953 100644 --- a/pygeoapi/util.py +++ b/pygeoapi/util.py @@ -30,6 +30,7 @@ """Generic util functions used in the code""" from datetime import date, datetime, time +from decimal import Decimal import logging import yaml @@ -101,6 +102,8 @@ def json_serial(obj): if isinstance(obj, (datetime, date, time)): serial = obj.isoformat() return serial + elif isinstance(obj, Decimal): + return float(obj) msg = '{} type {} not serializable'.format(obj, type(obj)) LOGGER.error(msg)