Skip to content

Commit

Permalink
Merge pull request #169 from custom-components/ludeeus-patch-1
Browse files Browse the repository at this point in the history
Add ProductBarcodeData to GrocyJSONEncoder
  • Loading branch information
isabellaalstrom authored Jan 25, 2022
2 parents 89dfd84 + d986a25 commit 438a795
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions custom_components/grocy/json_encode.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import Any

from pygrocy.data_models.product import ProductBarcode
from pygrocy.grocy_api_client import ProductBarcodeData


class GrocyJSONEncoder(json.JSONEncoder):
Expand All @@ -14,6 +15,8 @@ def default(self, o: Any) -> Any:

if isinstance(o, ProductBarcode):
return o.barcode
if isinstance(o, ProductBarcodeData):
return o.barcode
if isinstance(o, datetime):
return o.isoformat()
if isinstance(o, set):
Expand Down

0 comments on commit 438a795

Please sign in to comment.