http: use simplejson to properly handle the nan -> null serialisation
3 files changed, 10 insertions(+), 8 deletions(-)

M setup.py
M test/test_http.py
M tshistory_supervision/http.py
M setup.py +1 -0
@@ 12,6 12,7 @@ setup(name='tshistory_supervision',
 
       packages=['tshistory_supervision'],
       install_requires=[
+          'simplejson',
           'tshistory >= 0.18.0'
       ],
       entry_points={

          
M test/test_http.py +5 -5
@@ 34,10 34,10 @@ def test_supervision_json(client):
     res = client.get('/series/supervision?name=test-edited')
     df = pd.read_json(res.text, orient='index')
     assert_df("""
-                           markers  series
-2020-01-01 00:00:00+00:00    False       0
-2020-01-02 00:00:00+00:00    False       1
-2020-01-03 00:00:00+00:00     True      42
+                           series  markers
+2020-01-01 00:00:00+00:00       0    False
+2020-01-02 00:00:00+00:00       1    False
+2020-01-03 00:00:00+00:00      42     True
 """, df)
 
     res = client.get('/series/supervision?name=test-edited&format=tshpack')

          
@@ 191,4 191,4 @@ def test_edited_with_timezone(client):
         'tzone': 'Europe/Paris',
         '_keep_nans': json.dumps(True)
     })
-    assert 'NaN' in res.text  # oops, we'd like a nul !
+    assert 'null' in res.text

          
M tshistory_supervision/http.py +4 -3
@@ 1,5 1,4 @@ 
-import json
-
+import simplejson as json
 import pandas as pd
 from psyl import lisp
 

          
@@ 125,7 124,9 @@ class supervision_httpapi(httpapi):
                             k.isoformat(): v
                             for k, v in df.to_dict(orient='index').items()
                         }
-                        response = make_response(out)
+                        response = make_response(
+                            json.dumps(out, ignore_nan=True)
+                        )
                     else:
                         response = make_response('null')
                     response.headers['Content-Type'] = 'text/json'