简体   繁体   中英

Python SKIP element in JSON

I would like to get an element from the JSON tree

dataMod = data['products'][VARIABLE]['bla']['bla']

but I faced an issue when one of the element in this tree have VARIABLE inside, it is any clean way of skipping it? like:

dataMod = data['products'][*]['bla']['bla']

ANSWER:

for p in data['products']:
     skipPLU = data['products'][p]
     productPLU = skipPLU['bla']['bla']

Is this what you want?

head = data['products']

for skip in head :
    for data in head[skip]:
        print(head[skip][data]['bla']['bla'])

This will get all data under data['products'][VARIABLE]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM