Skip to content

Commit

Permalink
switch numeric decimal in json encoder
Browse files Browse the repository at this point in the history
  • Loading branch information
afourmy committed Jul 9, 2019
1 parent 37fd0dd commit 60e267d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions eNMS/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from decimal import Decimal
from flask import Flask, jsonify, make_response, render_template
from flask_assets import Bundle
from flask.json import JSONEncoder
from flask.wrappers import Request, Response
from pathlib import Path
from sqlalchemy import Numeric
from sqlalchemy.orm import configure_mappers
from typing import Any, Tuple

Expand Down Expand Up @@ -32,9 +32,9 @@ def register_modules(app: Flask) -> None:
def configure_encoder(app: Flask) -> None:
class CustomJSONEncoder(JSONEncoder):
def default(self, obj: Any) -> Any:
if isinstance(obj, Numeric):
if isinstance(obj, Decimal):
return str(obj)
return JSONEncoder.default(self, obj)
return super().default(obj)

app.json_encoder = CustomJSONEncoder

Expand Down

0 comments on commit 60e267d

Please sign in to comment.