using Python, I do some traitments, it's works but not the iteration. My json file is something like this :
{
"entities": [
{
"id":"int_id1",
"name":"name1"
"details":{
"age":[
"22"
],
}
},
{
"id":"int_id2",
"name":"name2"
"details":{
"age":[
"22"
],
}
},
{
"id":"int_id3",
"name":"name3"
"details":{
"age":[
"22"
],
}
}
]
}
I'm trying to do traitments on, but it's works only on the first iteration. how can I fix it to iterate the others element. I tried :
entities_file = open("from_emplacement")
json_entities_data = json.load(entities_file)
i=0;
for entity in json_entities_data:
answer = json_entities_data[entity][i]["details"][0]
if(condition):
....
i+=1;
for entity in json_entities_data["entities"]:is a place to start. Stop usingi; it's more trouble than benefit, because it has you iterating over two axes when you should only be moving along one.json.load()is completed, you just have Python data; it's no longer JSON data at all, and your question is not in any way JSON-specific. Thus, it would be a valid simplification from this question to just express your input as a Python data structure and remove JSON from the question entirely.