Below is a nested json I am using:
{
"9": {
"uid": "9",
"name": "pedro",
"mail": "pedro@pedro.com",
"roles": [
"authenticated",
"administrator"
],
"user_status": "1"
},
"10": {
"uid": "10",
"name": "Rosa",
"mail": "rosa@rosa.com",
"roles": [
"authenticated",
"administrator"
],
"user_status": "1"
},
"11": {
"uid": "11",
"name": "Tania",
"mail": "tania@tania.com",
"roles": [
"authenticated",
"administrator"
],
"user_status": "1"
}
}
Each first key is different from the rest. I need to extract the information between each of the keys, e.g. uid, name, mail, etc but not interested on the key id (9,10,11). Is there any way to achieve this without passing the key id on the code?
Below is what I’ve attempted thus far:
import json
outputuids = {
"9": {
"uid": "9",
"name": "pedro",
"mail": "pedro@pedro.com",
"roles": [
"authenticated",
"administrator"
],
"user_status": "1"
},
"10": {
"uid": "10",
"name": "Rosa",
"mail": "rosa@rosa.com",
"roles": [
"authenticated",
"administrator"
],
"user_status": "1"
},
"11": {
"uid": "11",
"name": "Tania",
"mail": "tania@tania.com",
"roles": [
"authenticated",
"administrator"
],
"user_status": "1"
}
}
data1 = json.loads(outputuids)
for i in data1:
fuid=data1['9']['uid']
fname=data1['9']['name']
print (fuid + fname)