Skip to content

Commit 125b23f

Browse files
NatalyaGrigorevaNatalia Grigoreva
authored andcommitted
update orjson package
1 parent 64b0b17 commit 125b23f

File tree

8 files changed

+139
-148
lines changed

8 files changed

+139
-148
lines changed

docs/http_snippets/update_snippets_with_responses.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import logging
44
from http import HTTPStatus
55

6-
import requests
7-
import simplejson
86
import argparse
7+
import orjson as json
8+
import requests
99

1010
parser = argparse.ArgumentParser()
1111
parser.add_argument("prefix", help="Snippets prefix to process. Like 'minimal_api', 'relationship_', etc")
@@ -14,7 +14,6 @@
1414
log = logging.getLogger(__name__)
1515

1616
SNIPPETS_DIR = "snippets"
17-
SORT_KEYS_ON_DUMP = True
1817
SNIPPET_RESULT_POSTFIX = "_result"
1918
REMOVE_PYTHON_SNIPPET = True
2019

@@ -83,11 +82,10 @@ def run_request_for_module(module_name: str):
8382
if response.content:
8483
# TODO: handle non-json response?
8584
http_response_text.append(
86-
simplejson.dumps(
85+
json.dumps(
8786
response.json(),
88-
sort_keys=SORT_KEYS_ON_DUMP,
89-
indent=2,
90-
),
87+
option=json.OPT_INDENT_2 | json.OPT_SORT_KEYS,
88+
).decode(),
9189
)
9290

9391
http_response_text.append("")

docs/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
fastapi<0.100.0
2+
orjson>=3.10.15
23
pydantic<2
3-
simplejson>=3.17.6
44
sphinx
55
sphinx_rtd_theme
66
sqlalchemy<2

fastapi_jsonapi/exceptions/handlers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from fastapi import Request
2-
from fastapi.responses import JSONResponse
2+
from fastapi.responses import ORJSONResponse as JSONResponse
33

44
from fastapi_jsonapi.exceptions import HTTPException
55

fastapi_jsonapi/querystring.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
)
1212
from urllib.parse import unquote
1313

14-
import simplejson as json
14+
import orjson as json
1515
from fastapi import (
1616
FastAPI,
1717
Request,

poetry.lock

Lines changed: 90 additions & 96 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ classifiers = [
2929
dependencies = [
3030
"fastapi>=0.79.0",
3131
"pydantic>=1.9.1",
32-
"simplejson>=3.17.6",
32+
"orjson==3.10.15",
3333
"uvicorn>=0.18.2",
3434
]
3535

@@ -79,7 +79,7 @@ package-mode = false
7979
python = "^3.9"
8080
fastapi = ">=0.79.0"
8181
pydantic = ">=1.9.1"
82-
simplejson = ">=3.17.6"
82+
orjson = "3.10.15"
8383
uvicorn = ">=0.18.2"
8484

8585
sqlalchemy = { version = ">=1.4.39", optional = true, extras = ["asyncio"] }

0 commit comments

Comments
 (0)