You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/howto.rst
+16Lines changed: 16 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -58,6 +58,22 @@ or a ``list`` of ``str`` values.
58
58
59
59
Full example: :download:`query_params.py <examples/query_params.py>`
60
60
61
+
JSON
62
+
----
63
+
64
+
:meth:`HTTPClient.request() <treq.client.HTTPClient.request>` supports a *json* keyword argument that gives a data structure to serialize as JSON (using :func:`json.dumps()`).
65
+
This also implies a ``Content-Type: application/json`` request header.
66
+
The *json* parameter is mutually-exclusive with *data*.
67
+
68
+
The :meth:`_Response.json()` method decodes a JSON response body.
69
+
It buffers the whole response and decodes it with :func:`json.loads()`.
70
+
71
+
.. literalinclude:: examples/json_post.py
72
+
:linenos:
73
+
:pyobject: main
74
+
75
+
Full example: :download:`json_post.py <examples/json_post.py>`
0 commit comments