1
0
mirror of https://github.com/taigaio/taiga-back synced 2025-10-06 00:02:52 +02:00
Files
taiga-back/taiga/base/utils/json.py
2021-04-15 13:06:41 +02:00

30 lines
788 B
Python

# -*- coding: utf-8 -*-
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Copyright (c) 2021-present Kaleidos Ventures SL
from django.utils.encoding import force_text
from taiga.base.api.utils import encoders
import json
def dumps(data, ensure_ascii=True, encoder_class=encoders.JSONEncoder, indent=None):
return json.dumps(data, cls=encoder_class, ensure_ascii=ensure_ascii, indent=indent)
def loads(data):
if isinstance(data, bytes):
data = force_text(data)
return json.loads(data)
load = json.load
# Some backward compatibility that should
# be removed in near future.
to_json = dumps
from_json = loads