i get this from lambda api gateway. how can i get {\\n "a":"b",\\n "c":"d",\\n "e":"f",\\n "g":"h"\\n} to json style ?
"------WebKitFormBoundarySfqiG2UABUZYF7Ir\r\n
Content-Disposition: form-data;
name=\"upload-file\";
filename=\"example.json\"\r\n
Content-Type: application/json\r\n\r\n
{\n \"a\":\"b\",\n \"c\":\"d\",\n \"e\":\"f\",\n \"g\":\"h\"\n}
\r\n------WebKitFormBoundarySfqiG2UABUZYF7Ir--"
i want make this {\\n "a":"b",\\n "c":"d",\\n "e":"f",\\n "g":"h"\\n}
to
{
"a":"b",
"c":"d",
"e":"f",
"g":"h"
}
How do you handle a response to get this?
Try this
import json
result = json.loads(x[x.find('{'): x.find('}')+1])
x is your string
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.