How to convert JSON to a pure array?
I have JSON like this
{
"lastUpdateId": 40104114357,
"bids": [
[
"35074.17000000",
"1.70502000"
],
[
"35073.93000000",
"0.00070000"
],
[
"35073.71000000",
"0.00066000"
]
],
"asks": [
[
"35074.18000000",
"3.85961000"
],
[
"35074.19000000",
"0.07203000"
],
[
"35074.20000000",
"0.02492000"
]
]
}
I first set the JSON code to the json variable, and then try the following:
cmd.URL β 'api.binance.com/api/v3/depth?symbol=BTCUSDT&limit=3'
β’responseβcmd.Run
[rc: 0 | msg: | HTTP Status: 200 "OK" | β’Data: 238]
json β response.Data
json
{"lastUpdateId":40104167506,"bids":[["35055.80000000","3.00810000"],["35055.55000000","0.57010000"],["35055.54000000","0.1
0000000"]],"asks":[["35055.81000000","0.88501000"],["35055.88000000","0.01288000"],["35055.89000000","0.02704000"]]}
data β βJSON json
data.asks
βββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββ
βββββββββββββββββ¬ββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββ¬ββββββββββββ
ββ35055.81000000β0.88501000βββ35055.88000000β0.01288000βββ35055.89000000β0.02704000ββ
βββββββββββββββββ΄ββββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββ΄ββββββββββββ
βββββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββ
But data.asks contains NameSpace with sub-namespace, but I need just array, like this:
ββββββββββββββββββ¬βββββββββββββββββ¬βββββββββββββββββ
β35055.81 0.88501β35055.88 0.01288β35055.89 0.02704β
ββββββββββββββββββ΄βββββββββββββββββ΄βββββββββββββββββ
How do I do that?
I read its:
- http://help.dyalog.com/latest/index.htm#Language/System%20Functions/json.htm
- https://xpqz.github.io/learnapl/io.html
but it didn’t help me
>Solution :
Couldn’t you just convert the strings to numbers by executing β each inner item ¨¨?
⨨ data.asks
ββββββββββββββββββ¬βββββββββββββββββ¬ββββββββββββββββ
β35074.18 3.85961β35074.19 0.07203β35074.2 0.02492β
ββββββββββββββββββ΄βββββββββββββββββ΄ββββββββββββββββ
Note: The actual numbers in my sample output are taken from your sample input, but don’t match your sample output, which may be based on a different input.