You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the assistant for deserializing a JSON string that contains 3 members with identical keys, I get the following output :
const char* balance = elem["balance"]; // "0.00000000", "0.00000001", "0.00000000"
How would I get only the 2nd parameter ? I looked at using a filter for getting only asset BNB (see below) but I can't figure it out using the documentation, doesn't seem to have that feature to only extract only balance value for asset==BNB ?
This is the complete JSON string to deserialize : [{"accountAlias":"mYfREZSgFzAu","asset":"USDT","balance":"0.00000000","crossWalletBalance":"0.00000000","crossUnPnl":"0.00000000","availableBalance":"0.00000000","maxWithdrawAmount":"0.00000000"},{"accountAlias":"mYfREZSgFzAu","asset":"BNB","balance":"0.00000001","crossWalletBalance":"0.00000000","crossUnPnl":"0.00000000","availableBalance":"0.00000000","maxWithdrawAmount":"0.00000001"},{"accountAlias":"mYfREZSgFzAu","asset":"BUSD","balance":"0.00000000","crossWalletBalance":"0.00000000","crossUnPnl":"0.00000000","availableBalance":"0.00000000","maxWithdrawAmount":"0.00000000"}]
And this is the code I'm using (based on assistant):
It's currently not possible to filter elements of arrays because I couldn't find a satisfying API.
See this older answer for details.
I'm still opened to suggestions.
Hi,
Using the assistant for deserializing a JSON string that contains 3 members with identical keys, I get the following output :
const char* balance = elem["balance"]; // "0.00000000", "0.00000001", "0.00000000"
How would I get only the 2nd parameter ? I looked at using a filter for getting only asset BNB (see below) but I can't figure it out using the documentation, doesn't seem to have that feature to only extract only balance value for asset==BNB ?
This is the complete JSON string to deserialize : [{"accountAlias":"mYfREZSgFzAu","asset":"USDT","balance":"0.00000000","crossWalletBalance":"0.00000000","crossUnPnl":"0.00000000","availableBalance":"0.00000000","maxWithdrawAmount":"0.00000000"},{"accountAlias":"mYfREZSgFzAu","asset":"BNB","balance":"0.00000001","crossWalletBalance":"0.00000000","crossUnPnl":"0.00000000","availableBalance":"0.00000000","maxWithdrawAmount":"0.00000001"},{"accountAlias":"mYfREZSgFzAu","asset":"BUSD","balance":"0.00000000","crossWalletBalance":"0.00000000","crossUnPnl":"0.00000000","availableBalance":"0.00000000","maxWithdrawAmount":"0.00000000"}]
And this is the code I'm using (based on assistant):
StaticJsonDocument<768> doc;
deserializeJson(doc, input);
for (JsonObject elem : doc.as()) {
const char* balance = elem["balance"]; // "0.00000000", "0.00000001", "0.00000000"
}
Serial.println(balance);
this gives me:
0.00000000
0.00000001
0.00000000
I need only the balance for asset BNB being 0.00000001
How to ? thanks !
The text was updated successfully, but these errors were encountered: