Explorar o código

support numpy types (#1033)

resolves #469

Co-authored-by: Fred Lefévère-Laoide <Fred.Lefevere-Laoide@Taipy.io>
Fred Lefévère-Laoide hai 1 ano
pai
achega
641e61596e
Modificáronse 1 ficheiros con 3 adicións e 0 borrados
  1. 3 0
      taipy/gui/_renderers/json.py

+ 3 - 0
taipy/gui/_renderers/json.py

@@ -16,6 +16,7 @@ from datetime import date, datetime, time, timedelta
 from json import JSONEncoder
 from pathlib import Path
 
+import numpy
 import pandas
 from flask.json.provider import DefaultJSONProvider
 
@@ -48,6 +49,8 @@ class _DefaultJsonAdapter(JsonAdapter):
             return str(o)
         if isinstance(o, (timedelta, pandas.Timedelta)):
             return str(o)
+        if isinstance(o, numpy.generic):
+            return getattr(o, "tolist", lambda: o)()
 
 
 class _TaipyJsonAdapter(object, metaclass=_Singleton):