I have an example like this:
listing = {
"ret_code": 0,
"ret_msg": "ok",
"ext_code": "",
"result": {
"pages": 10,
"data": [ <--- would like to get ALL information under "data"
{
"user_id": 1,
"qty": 2,
"order_status": "Filled",
"ext_fields": {
"close_on_trigger": true,
"orig_order_type": "BLimit",
"o_req_num": -34799032763,
"xreq_type": "x_create"
},
"last_exec_price": 7070.5,
"leaves_qty": 0,
]
[... snip ...]
}
Please note: the ~full text~ being worked with is on the "Response" structure on this page: https://bybit-exchange.github.io/docs/inverse/#t-getactive
What I would like to do is get the information under the "data" attribute (i.e. something like listing["data"]). I would like to get back everything under the "data" attribute.
How can this be done?
ETA: I have tried:
data = [item for item in listing if item.attribute == 'data']
But my result was as follows:
Traceback (most recent call last):
File "../trade_bybit/trade_bybit.py", line 198, in get_recent_orders
data = [item for item in listing if item.attribute == 'data']
File "../trade_bybit/trade_bybit.py", line 198, in <listcomp>
data = [item for item in listing if item.attribute == 'data']
AttributeError: 'dict' object has no attribute 'attribute'
ETA: @Joshua Varghese Thanks for the hint. I tried
[item for item in listing if item == 'data']
but the answer I got was:
[]
item.attributewhen you can do[item for item in listing if item == 'data']