Code: Select all
BNB_Data := json.load(json_response)
Code: Select all
{
"assets": [
{
"asset": "BTC",
"availableBalance": "0.00000000",
"crossUnPnl": "0.00000000",
"crossWalletBalance": "0.00000000",
"initialMargin": "0.00000000",
"maintMargin": "0.00000000",
"marginAvailable": 1,
"marginBalance": "0.00000000",
"maxWithdrawAmount": "0.00000000",
"openOrderInitialMargin": "0.00000000",
"positionInitialMargin": "0.00000000",
"unrealizedProfit": "0.00000000",
"updateTime": 0,
"walletBalance": "0.00000000"
},
{
"asset": "BUSD",
"availableBalance": "10.00000000",
"crossUnPnl": "0.00000000",
"crossWalletBalance": "10.00000000",
"initialMargin": "0.00000000",
"maintMargin": "0.00000000",
"marginAvailable": 1,
"marginBalance": "10.00000000",
"maxWithdrawAmount": "10.00000000",
"openOrderInitialMargin": "0.00000000",
"positionInitialMargin": "0.00000000",
"unrealizedProfit": "0.00000000",
"updateTime": 1630130417327,
"walletBalance": "10.00000000"
}
],
"availableBalance": "0.00000000",
"canDeposit": 1,
"canTrade": 1,
"canWithdraw": 1,
"feeTier": 0,
"maxWithdrawAmount": "0.00000000",
"positions": [
{
"entryPrice": "0.0",
"initialMargin": "0",
"isolated": 0,
"isolatedWallet": "0",
"leverage": "20",
"maintMargin": "0",
"maxNotional": "25000",
"notional": "0",
"openOrderInitialMargin": "0",
"positionAmt": "0.0",
"positionInitialMargin": "0",
"positionSide": "BOTH",
"symbol": "RAYUSDT",
"unrealizedProfit": "0.00000000",
"updateTime": 0
},
{
"entryPrice": "0.0",
"initialMargin": "0",
"isolated": 0,
"isolatedWallet": "0",
"leverage": "20",
"maintMargin": "0",
"maxNotional": "25000",
"notional": "0",
"openOrderInitialMargin": "0",
"positionAmt": "0",
"positionInitialMargin": "0",
"positionSide": "BOTH",
"symbol": "CTSIUSDT",
"unrealizedProfit": "0.00000000",
"updateTime": 0
}
],
"totalCrossUnPnl": "0.00000000",
"totalCrossWalletBalance": "0.00000000",
"totalInitialMargin": "0.00000000",
"totalMaintMargin": "0.00000000",
"totalMarginBalance": "0.00000000",
"totalOpenOrderInitialMargin": "0.00000000",
"totalPositionInitialMargin": "0.00000000",
"totalUnrealizedProfit": "0.00000000",
"totalWalletBalance": "0.00000000",
"updateTime": 0
}
Question:
Q1:
If I want to output (i.e. using msgbox) all of the assets, how can I achieve that? I tried many approaches but just keep return nothing...
Code: Select all
msg := "assets: " BNB_Data["assets"]
msg := "assets: " BNB_Data.assets
msg := "assets: " BNB_Data[0]
If I want to return all the relevant parameters for a particular asset (i.e. BTC), how can I do that? I tried quite a few approach and don't work as well..
Code: Select all
msg := "BTC: " BNB_Data["assets=BTC"]
msg := "assets: " BNB_Data.assets["BTC"]
msg := "assets: " BNB_Data.assets[0]
Is there any good tutorials about navigating/operating a JSON AHK object? I searched a bit, I can only find the ones about AHK object, and not really teaching much about how to navigate a "JSON" obj...