From ffef30af0519134e1b4178bd6da19d28b2d9a4f0 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Mon, 21 Aug 2023 12:43:54 +0200 Subject: [PATCH 1/2] Fix docs on JSON type --- docs/usage/types/json.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/usage/types/json.md b/docs/usage/types/json.md index 66f3005572..216d39d5ab 100644 --- a/docs/usage/types/json.md +++ b/docs/usage/types/json.md @@ -4,7 +4,7 @@ You can use the `Json` data type to make Pydantic first load a raw JSON string before validating the loaded data into the parametrized type: -```py group='json' +```py from typing import Any, List from pydantic import BaseModel, Json, ValidationError @@ -59,7 +59,7 @@ except ValidationError as e: When you dump the model using `model_dump` or `model_dump_json`, the dumped value will be the result of validation, not the original JSON string. However, you can use the argument `round_trip=True` to get the original JSON string back: -```py group='json' +```py print(ConstrainedJsonModel(json_obj='[1, 2, 3]').model_dump_json()) #> {"json_obj":[1,2,3]} print( From f94343283088a76907f41b5702f047616ee074d9 Mon Sep 17 00:00:00 2001 From: David Montague <35119617+dmontagu@users.noreply.github.com> Date: Mon, 21 Aug 2023 06:32:19 -0600 Subject: [PATCH 2/2] Fix issue --- docs/usage/types/json.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/usage/types/json.md b/docs/usage/types/json.md index 216d39d5ab..2109f71ada 100644 --- a/docs/usage/types/json.md +++ b/docs/usage/types/json.md @@ -4,7 +4,7 @@ You can use the `Json` data type to make Pydantic first load a raw JSON string before validating the loaded data into the parametrized type: -```py +```py group="json" from typing import Any, List from pydantic import BaseModel, Json, ValidationError @@ -59,7 +59,7 @@ except ValidationError as e: When you dump the model using `model_dump` or `model_dump_json`, the dumped value will be the result of validation, not the original JSON string. However, you can use the argument `round_trip=True` to get the original JSON string back: -```py +```py group="json" print(ConstrainedJsonModel(json_obj='[1, 2, 3]').model_dump_json()) #> {"json_obj":[1,2,3]} print(