/httpj

A fork of httpx with custom JSON serializer support

Primary LanguagePythonBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

HTTPJ

HTTPJ -A fork of httpx with support for a custom JSON serializer.

Test Suite Package version

  • HTTPJ is nearly identical to HTTPX. The main difference lies in two extra parameters, json_serialize and json_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)