I have this payload:
payload = {
"cluster": "analytics",
"id_pipeline": "123456789",
"schema_compatibility": "backward",
"branch": "production"
}
And I need to remove the element "id_pipeline" and its value ("123456789").
Any suggestions? I made this code but this errors appears: "'str' object does not support item deletion"
for element in payload_data:
if 'id_pipeline' in element:
del element['id_pipeline']
The desirable output payload is something like this:
payload = {
"cluster": "analytics",
"schema_compatibility": "backward",
"branch": "production"
}
Obs: I need to keep json format.

del payload['id_pipeline']dictcalledpayloadand you want to remove an element? Did you meandel payload["id_pipeline"]?json.loads, delete the key and write the resulting dictionary back to the JSON file.