From ab86c5adeab5ef759f9475e74ac39c466c8f8ef9 Mon Sep 17 00:00:00 2001 From: Abdelrahman Ghanem Date: Mon, 26 Apr 2021 13:46:23 +0200 Subject: [PATCH] remove encoding option from json field... (#584) prepare for python 3.9 support --- jumpscale/core/base/fields.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/jumpscale/core/base/fields.py b/jumpscale/core/base/fields.py index cec8baead..265f8ef44 100644 --- a/jumpscale/core/base/fields.py +++ b/jumpscale/core/base/fields.py @@ -1041,7 +1041,7 @@ def to_raw(self, value): class Json(String): - def __init__(self, default="{}", encoding="utf-8", **kwargs): + def __init__(self, default="{}", **kwargs): """ Json field, will check if the value is a valid json string. @@ -1049,10 +1049,8 @@ def __init__(self, default="{}", encoding="utf-8", **kwargs): Args: default (str, optional): default value. Defaults to "{}" - encoding: encoding to be used when serializing the value. Defaults to "utf-8" kwargs: other keyword arguments supported by `String` """ - self.encoding = encoding super().__init__(default=default, **kwargs) def validate(self, value): @@ -1072,7 +1070,7 @@ def validate(self, value): # if it's a string, try to load it try: - json.loads(value, encoding=self.encoding) + json.loads(value) except Exception as e: raise ValidationError(f"'{value}' isn't a valid json, {e}") from e