HTTPJ -A fork of httpx with support for a custom JSON serializer.
- HTTPJ is nearly identical to HTTPX. The main difference lies in two extra parameters,
json_serialize
andjson_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 httpj
Now, 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)