0

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"
}

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

i get this from event['body-json'] . i will try it
I update code , it not a best way but could work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.