Skip to content

Commit

Permalink
Align JSON settings to v2 changes (#34)
Browse files Browse the repository at this point in the history
In v2 we should use `json_settings` from `blacksheep.settings.json`
    instead of `json_plugin` from `blacksheep.plugins`
  • Loading branch information
tyzhnenko authored Jan 3, 2024
1 parent 2226060 commit 3f229a9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions docs/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ By default, the built-in `json` module is used for serializing and
deserializing objects, but this can be changed in the way illustrated below.

```python
from blacksheep.plugins import json
from blacksheep.settings.json import json_settings


def custom_loads(value):
Expand All @@ -81,7 +81,7 @@ def custom_dumps(value):
"""


json.use(
json_settings.use(
loads=custom_loads,
dumps=custom_dumps,
)
Expand All @@ -101,14 +101,14 @@ deserialization with the built-in [`responses`](../responses/) and
```python
import orjson

from blacksheep.plugins import json
from blacksheep.settings.json import json_settings


def serialize(value) -> str:
return orjson.dumps(value).decode("utf8")


json.use(
json_settings.use(
loads=orjson.loads,
dumps=serialize,
)
Expand Down Expand Up @@ -156,7 +156,7 @@ this possibility, it doesn't handle objects inside lists, `@dataclass`, or
import json
from typing import Any

from blacksheep.plugins import json as json_plugin
from blacksheep.settings.json import json_settings
from essentials.json import dumps


Expand Down Expand Up @@ -188,7 +188,7 @@ def custom_dumps(value: Any) -> str:
return default_json_dumps(value)


json_plugin.use(
json_settings.use(
loads=custom_loads,
dumps=custom_dumps,
)
Expand Down

0 comments on commit 3f229a9

Please sign in to comment.