From 4a6fb41e8fd9471ad02e4898f5791c67b1dd98b0 Mon Sep 17 00:00:00 2001 From: Dmytro Tyzhnenko Date: Wed, 3 Jan 2024 00:22:36 +0200 Subject: [PATCH] Align JSON settings to v2 changes In v2 we should use `json_settings` from `blacksheep.settings.json` instead of `json_plugin` from `blacksheep.plugins` --- docs/settings.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/settings.md b/docs/settings.md index f451a7e..e5bd8d6 100644 --- a/docs/settings.md +++ b/docs/settings.md @@ -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): @@ -81,7 +81,7 @@ def custom_dumps(value): """ -json.use( +json_settings.use( loads=custom_loads, dumps=custom_dumps, ) @@ -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, ) @@ -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 @@ -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, )