Python equivalent of wrapping POST payload in single quotes Python equivalent of wrapping POST payload in single quotes json json

Python equivalent of wrapping POST payload in single quotes


Well, "multiple json objects" is not a valid json, until it's a list of objects.

Generally, python doesn't care (just like any other network tool), json is just data format, and you need a different one. So you need to construct text payload yourself, i.e. json.dumps(payload1) + json.dumps(payload2), and send it via your network client as "raw" data.

I highly doubt that mainstream http libraries provide such usecase out of the box.


Not sure on reason for downvotes, i.e. requests library (which is kinda standard de-facto for high-level networking) have smart processing for payloads:

requests.post(url, data={'v1': 1, 'v2': 2})  # will encode it as form datarequests.post(url, json={'v1': 1, 'v2': 2})  # will encode as jsonrequests.post(url, data="{'v1': 1}{'v2': 2}")  # will send as-is

Json has nothing to do with http itself, it's just a way to serialize data. Most clients will eventually use urllib, which doesn't care at all, the only question is if library gives easy way to send data raw