Questions tagged [orjson]

12 questions
14
votes
3 answers

How to resolve pydantic model is not JSON serializable

I am having below pydantic models. class SubModel(BaseModel): columns: Mapping key: List[str] required: Optional[List[str]] class Config: anystr_strip_whitespace: True extra: Extra.allow …
Naxi
  • 1,504
  • 5
  • 33
  • 72
5
votes
1 answer

pip install fastapi[all] is failing due to a rust component?

Hi I'm trying to install fastapi, but it seems to be failing when im installing orjson Here is the full error code: Building wheel for orjson (PEP 517) ... error ERROR: Command errored out with exit status 1: command:…
LearningNoob
  • 662
  • 6
  • 23
4
votes
2 answers

Unable to install orjson 3.3.0 on macOS 12.2.1 with Apple M1 chip

I am trying to install orjson==3.3.0 on my MacBook Pro with Apple M1 Pro chip running macOS Monterey 12.2.1. Python version: 3.8.9 Command used: pip install orjson==3.3.0 Error: Collecting orjson==3.3.0 Downloading orjson-3.3.0.tar.gz (654 kB) …
ttan
  • 41
  • 1
  • 3
4
votes
2 answers

orjson and json dumps method not the same python3.8

I have switched to orjson since it is faster, but this has caused an issue I have had for a fair amount of time now but never thought anything of it. I finally decided to do tests and these were my tests. import orjson, json data =…
CoN
  • 41
  • 1
  • 1
  • 6
2
votes
1 answer

How to read the request body using orjson library in FastAPI?

I am writing code to receive a JSON payload in FastAPI. Here is my code: from fastapi import FastAPI, status, Request from fastapi.responses import ORJSONResponse import uvicorn import asyncio import orjson app = FastAPI() @app.post("/",…
Nguyen
  • 33
  • 5
1
vote
0 answers

Python's orjson rised JSONDecodeError: str is not valid UTF-8

I trid to load json file with standart json library. It's works good but slowly: with open(file, 'r', encoding="utf-8") as jfile: lines = json.loads(jfile.read()) I try orjson librery, but the same code rise JSONDecodeError: str is not valid…
Myky
  • 21
  • 2
1
vote
3 answers

Apache beam(2.32.0) installation fails

We have some issues deploying our GCP Dataflow pipeline. After some analysis, found that the latest version of apache-beam has some issues while installing. To replicate the issue I created a virtualenv and ran the below pip install…
Prasad Sawant
  • 205
  • 1
  • 15
1
vote
1 answer

How to JSONIFY a dict having a pydantic model

I am new to pydantic and am stuck. Below code is throwing error TypeError: Type is not JSON serializable: Person from pydantic import BaseModel,Extra from typing import Mapping, Optional, Any,List from orjson import dumps class Address(BaseModel): …
Naxi
  • 1,504
  • 5
  • 33
  • 72
1
vote
1 answer

How to set response class in FastAPI?

Using orjson to serializing response has a remarkable effect on the speed of fastAPI restful services, specifically for very big objects. As I have read in the official documentation, we can use the response class directly as a parameter of api…
1
vote
3 answers

How do I setup rust toolchain for orjson python library build in an alpine docker image?

I have been struggling with this and I need some help. I am trying to create a docker image of my python app. My App uses orjson, the fast JSON library for python. Parts of this library is built using rust so I need the rust toolchain. Now the…
vivekv
  • 2,238
  • 3
  • 23
  • 37
0
votes
0 answers

orjson installation error during installation of cloned torch lighetning on ppc system (IBM)

I am trying to install lightening from setu.py but it fails while installing osjson-3.8.0. So, I tried to manually install it using pip install --upgrade orjson but it given error in pyproject.toml file. Collecting orjson Using cached…
Mohbat Tharani
  • 550
  • 1
  • 6
  • 22
0
votes
2 answers

Why Http headers is being vanished when using ORJSONResponse() in fastAPI?

Http headers can be modified in fastAPI; however when I tried to use faster serializer (in this instance ORJSONResponse) in order to have faster response, all added or modified headers confusingly is being vanished. I don't have any idea that why it…