File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -317,12 +317,10 @@ def explore_ocds(request, pk):
317
317
def ocds_show_data (json_data , ocds_show_deref_schema ):
318
318
new_json_data = copy .deepcopy (json_data )
319
319
add_extra_fields (new_json_data , ocds_show_deref_schema )
320
- return json .dumps (new_json_data , cls = DecimalEncoder )
320
+ return json .dumps (new_json_data , default = default )
321
321
322
322
323
- # From stackoverflow: https://stackoverflow.com/questions/1960516/python-json-serialize-a-decimal-object
324
- class DecimalEncoder (json .JSONEncoder ):
325
- def default (self , o ):
326
- if isinstance (o , Decimal ):
327
- return float (o )
328
- return super ().default (o )
323
+ def default (self , obj ):
324
+ if isinstance (obj , Decimal ):
325
+ return float (obj )
326
+ return json .JSONEncoder ().default (obj )
You can’t perform that action at this time.
0 commit comments