I am trying to write a code that reads the very outside of the json file data.json
, which would output the outside of it. [RSI, MOM, MOM_RSI]
and the total subsections of all three of the sections. Each subsection contains TradingPair and Status
. Is there a way I could do this with using a list comprehension preferably or a for loop without using a for data in [RSI, MOM, MOM_RSI]
?
Code:
def reading():
with open('data.json') as f:
data = json.load(f)
return data
reading()
JSON File:
{
"RSI": [
{
"TradingPair": "BTCUSD",
"Status": "ACTIVE",
}
],
"MOM":[
{
"TradingPair": "BCHUSDT",
"Status": "PAUSED",
},
{
"TradingPair": "ETHUSDT",
"Status": "ACTIVE",
}
],
"MOM_RSI":[
{
"TradingPair": "BCHUSDT",
"Status": "PAUSED",
},
{
"TradingPair": "BTCUSDT",
"Status": "ACTIVE",
}
]
}