0

i have this data .

I parsed it to JSON and it worked for me some time ago

json_data = json.loads(data)
print(json_data['plp']['plp_products']) #OK

But now i have this error: "TypeError: string indices must be integers". If i print the "type" of json_data, gives me a str :

<class 'str'>

How could I transform that data to use it again as a JSON? I especially need to work with the node json_data['plp']['plp_products']

Thanks

0

1 Answer 1

5

I reproduced your error. The root cause is your data was actually json encoded twice, which means you have to decode twice to get data.

json_data = json.loads(data)
json_data = json.loads(json_data)
Sign up to request clarification or add additional context in comments.

Comments

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.