Reputation: 333
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
Upvotes: 0
Views: 435
Reputation: 166
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)
Upvotes: 5