HTTPJ HTTPX fork with custom JSON serializer support.
- HTTPJ is nearly identical to HTTPX. The main difference lies in two extra parameters,
json_serializeandjson_deserialize, which afford you precise control over the serialization and deserialization of your objects in JSON format. - HTTPJ will remain synchronized with the mainstream HTTPX until similar functionality emerges.
Install HTTPJ using pip:
pip install httpjNow, let's get started:
import datetime
import pprint
import httpj
import orjson
resp = httpj.post(
"https://postman-echo.com/post",
json={"dt": datetime.datetime.utcnow()},
json_serialize=lambda j: orjson.dumps(j, option=orjson.OPT_NAIVE_UTC), # optional
json_deserialize=orjson.loads, # optional
)
pprint.pprint(resp.json(), indent=4)