I’m trying to iterate through a json response, method is get.
this is the json
{
"snapshots" : [
{
"snapshot" : "First"},
{
"snapshot" : "Second"}
I would like to know if any of you have an easy way to iterate through this and get the value of "snapshot" key, with python 3.X
thanks in advance
>Solution :
Here an example
import json
var= """
{
"snapshots" : [
{
"snapshot" : "First"},
{
"snapshot" : "Second"}
]
}
"""
data = json.loads(var)
for snapshot in data["snapshots"]:
print(f'Value :{snapshot["snapshot"]}')
The output that i got :
Value :First
Value :Second