prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  CustomJsonEncoder drops currency information from Money instance
  Usually, we are using `settings.DEFAULT_CURRENCY` all over the place, however, there can be a bug, where `Money` is saved into `JSONField`, and `settings.DEFAULT_CURRENCY` changed meanwhile.
  
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `saleor/core/utils/json_serializer.py`
  Content:
  ```
  1 from django.core.serializers.json import (
  2     Deserializer as JsonDeserializer, DjangoJSONEncoder,
  3     Serializer as JsonSerializer)
  4 from prices import Money
  5 
  6 
  7 class Serializer(JsonSerializer):
  8     def _init_options(self):
  9         super()._init_options()
  10         self.json_kwargs['cls'] = CustomJsonEncoder
  11 
  12 
  13 class CustomJsonEncoder(DjangoJSONEncoder):
  14     def default(self, obj):
  15         if isinstance(obj, Money):
  16             return obj.amount
  17         return super().default(obj)
  18 
  19 
  20 Deserializer = JsonDeserializer
  21
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/saleor/core/utils/json_serializer.py b/saleor/core/utils/json_serializer.py
  --- a/saleor/core/utils/json_serializer.py
  +++ b/saleor/core/utils/json_serializer.py
  @@ -1,8 +1,12 @@
  +import json
  +
  +from django.core.serializers.base import DeserializationError
   from django.core.serializers.json import (
  -    Deserializer as JsonDeserializer, DjangoJSONEncoder,
  -    Serializer as JsonSerializer)
  +    DjangoJSONEncoder, PythonDeserializer, Serializer as JsonSerializer)
   from prices import Money
   
  +MONEY_TYPE = 'Money'
  +
   
   class Serializer(JsonSerializer):
       def _init_options(self):
  @@ -13,8 +17,32 @@
   class CustomJsonEncoder(DjangoJSONEncoder):
       def default(self, obj):
           if isinstance(obj, Money):
  -            return obj.amount
  +            return {
  +                '_type': MONEY_TYPE, 'amount': obj.amount,
  +                'currency': obj.currency}
           return super().default(obj)
   
   
  -Deserializer = JsonDeserializer
  +def object_hook(obj):
  +    if '_type' in obj and obj['_type'] == MONEY_TYPE:
  +        return Money(obj['amount'], obj['currency'])
  +    return obj
  +
  +
  +def Deserializer(stream_or_string, **options):
  +    """Deserialize a stream or string of JSON data. This is a slightly modified
  +    copy of Django implementation with additional argument <object_hook> in
  +    json.loads"""
  +    if not isinstance(stream_or_string, (bytes, str)):
  +        stream_or_string = stream_or_string.read()
  +    if isinstance(stream_or_string, bytes):
  +        stream_or_string = stream_or_string.decode()
  +    try:
  +        objects = json.loads(stream_or_string, object_hook=object_hook)
  +        yield from PythonDeserializer(objects, **options)
  +    except Exception as exc:
  +        # ugly construction to overcome pylint's warning
  +        # "The except handler raises immediately"
  +        if isinstance(exc, (GeneratorExit, DeserializationError)):
  +            raise
  +        raise DeserializationError() from exc
  
verification_info: {"golden_diff": "diff --git a/saleor/core/utils/json_serializer.py b/saleor/core/utils/json_serializer.py\n--- a/saleor/core/utils/json_serializer.py\n+++ b/saleor/core/utils/json_serializer.py\n@@ -1,8 +1,12 @@\n+import json\n+\n+from django.core.serializers.base import DeserializationError\n from django.core.serializers.json import (\n-    Deserializer as JsonDeserializer, DjangoJSONEncoder,\n-    Serializer as JsonSerializer)\n+    DjangoJSONEncoder, PythonDeserializer, Serializer as JsonSerializer)\n from prices import Money\n \n+MONEY_TYPE = 'Money'\n+\n \n class Serializer(JsonSerializer):\n     def _init_options(self):\n@@ -13,8 +17,32 @@\n class CustomJsonEncoder(DjangoJSONEncoder):\n     def default(self, obj):\n         if isinstance(obj, Money):\n-            return obj.amount\n+            return {\n+                '_type': MONEY_TYPE, 'amount': obj.amount,\n+                'currency': obj.currency}\n         return super().default(obj)\n \n \n-Deserializer = JsonDeserializer\n+def object_hook(obj):\n+    if '_type' in obj and obj['_type'] == MONEY_TYPE:\n+        return Money(obj['amount'], obj['currency'])\n+    return obj\n+\n+\n+def Deserializer(stream_or_string, **options):\n+    \"\"\"Deserialize a stream or string of JSON data. This is a slightly modified\n+    copy of Django implementation with additional argument <object_hook> in\n+    json.loads\"\"\"\n+    if not isinstance(stream_or_string, (bytes, str)):\n+        stream_or_string = stream_or_string.read()\n+    if isinstance(stream_or_string, bytes):\n+        stream_or_string = stream_or_string.decode()\n+    try:\n+        objects = json.loads(stream_or_string, object_hook=object_hook)\n+        yield from PythonDeserializer(objects, **options)\n+    except Exception as exc:\n+        # ugly construction to overcome pylint's warning\n+        # \"The except handler raises immediately\"\n+        if isinstance(exc, (GeneratorExit, DeserializationError)):\n+            raise\n+        raise DeserializationError() from exc\n", "issue": "CustomJsonEncoder drops currency information from Money instance\nUsually, we are using `settings.DEFAULT_CURRENCY` all over the place, however, there can be a bug, where `Money` is saved into `JSONField`, and `settings.DEFAULT_CURRENCY` changed meanwhile.\r\n\r\n\n", "before_files": [{"content": "from django.core.serializers.json import (\n    Deserializer as JsonDeserializer, DjangoJSONEncoder,\n    Serializer as JsonSerializer)\nfrom prices import Money\n\n\nclass Serializer(JsonSerializer):\n    def _init_options(self):\n        super()._init_options()\n        self.json_kwargs['cls'] = CustomJsonEncoder\n\n\nclass CustomJsonEncoder(DjangoJSONEncoder):\n    def default(self, obj):\n        if isinstance(obj, Money):\n            return obj.amount\n        return super().default(obj)\n\n\nDeserializer = JsonDeserializer\n", "path": "saleor/core/utils/json_serializer.py"}], "after_files": [{"content": "import json\n\nfrom django.core.serializers.base import DeserializationError\nfrom django.core.serializers.json import (\n    DjangoJSONEncoder, PythonDeserializer, Serializer as JsonSerializer)\nfrom prices import Money\n\nMONEY_TYPE = 'Money'\n\n\nclass Serializer(JsonSerializer):\n    def _init_options(self):\n        super()._init_options()\n        self.json_kwargs['cls'] = CustomJsonEncoder\n\n\nclass CustomJsonEncoder(DjangoJSONEncoder):\n    def default(self, obj):\n        if isinstance(obj, Money):\n            return {\n                '_type': MONEY_TYPE, 'amount': obj.amount,\n                'currency': obj.currency}\n        return super().default(obj)\n\n\ndef object_hook(obj):\n    if '_type' in obj and obj['_type'] == MONEY_TYPE:\n        return Money(obj['amount'], obj['currency'])\n    return obj\n\n\ndef Deserializer(stream_or_string, **options):\n    \"\"\"Deserialize a stream or string of JSON data. This is a slightly modified\n    copy of Django implementation with additional argument <object_hook> in\n    json.loads\"\"\"\n    if not isinstance(stream_or_string, (bytes, str)):\n        stream_or_string = stream_or_string.read()\n    if isinstance(stream_or_string, bytes):\n        stream_or_string = stream_or_string.decode()\n    try:\n        objects = json.loads(stream_or_string, object_hook=object_hook)\n        yield from PythonDeserializer(objects, **options)\n    except Exception as exc:\n        # ugly construction to overcome pylint's warning\n        # \"The except handler raises immediately\"\n        if isinstance(exc, (GeneratorExit, DeserializationError)):\n            raise\n        raise DeserializationError() from exc\n", "path": "saleor/core/utils/json_serializer.py"}]}