I have a different kind of JSON format. I am stuck on how to get the 1st Key alone.
My JSON RESPONSE:
resp={
"root[0]": {
"Name": "res1",
"region": "ca-1",
"tags": [
{
"name": "Environment",
"value": "TC1"
},
{
"name": "Test",
"value": "yes"
}
]
},
"root[3]": {
"Name": "Demo",
"region": "ca-1",
"tags": [
{
"name": "Test1",
"value": "check"
},
{
"name": "Test12",
"value": "yes"
}
]
} }
I want to take the Name and Region key and values alone. Note that root[] will have any number inside so I cant explicitly put the number as it changes every time.
Python Code
test = resp.get('Name')
test2= resp.get('region')
print(test,test2)
##Both prints None
Expected:
"Name": "res1",
"region": "ca-1",
"Name": "Demo",
"region": "ca-1"