jason question and list

10 views
Skip to first unread message

stefano cerbioni

unread,
Jul 20, 2022, 8:59:13 AMJul 20
to The Ring Programming Language
hi guys  the  problem is  i have  a symbol ticker  and i want  id symbol , i  call a  api  and the api return this string (is to much long i paste only a part)
Punk"},{"id":"peoplez","symbol":"lez","name":"Peoplez"},{"id":"peos","symbol":"peos","name":"pEOS"},{"id":"pepedex","symbol":"ppdex","name":"Pepedex"},{"id":"pepegold","symbol":"peps","name":"PEPS Coin"},{"id":"pepemoon","symbol":"pepe","name":"Pepemoon"},{"id":"pera-finance","symbol":"pera","name":"Pera Finance"},{"id":"perfect-world","symbol":"pfw","name":"Perfect World"},{"id":"peri-finance","symbol":"peri","name":"PERI Finance"},{"id":"perion","symbol":"perc","name":"Perion"},{"id":"perkle","symbol":"prkl","name":"Perkle"},{"id":"perlin","symbol":"perl","name":"PERL.eco"},{"id":"permission-coin","symbol":"ask","name":"Permission Coin"},{"id":"perpetual-protocol","symbol":"perp","name":"Perpetual Protocol"},{"id":"perpetual-wormhole","symbol":"perp","name":"Perpetual (Wormhole)"},{"id":"perpetuum-coin","symbol":"prp","name":"Perpetuum Coin"},{"id":"per-project","symbol":"per","name":"PER Project"},{"id":"perseus-fintech","symbol":"prs","name":"Perseus Fintech"},{"id":"persia","symbol":"persia","name":"Persia"},{"id":"persistence","symbol":"xprt","name":"Persistence"},{"id":"persistence-staked-xprt","symbol":"stkxprt","name":"pSTAKE Staked XPRT"},{"id":"perth-mint-gold-token","symbol":"pmgt","name":"Perth Mint Gold Token"},{"id":"peruvian-national-football-team-fan-token","symbol":"fpft","name":"Peruvian National Football Team Fan Token"},{"id":"pesabase","symbol":"pesa","name":"Pesabase"},{"id":"peseta-digital","symbol":"ptd","name":"Peseta Digital"},{"id":"pet-alliance","symbol":"pal","name":"Pet Alliance"},{"id":"petals","symbol":"pts","name":"Petals"},{"id":"pet-games","symbol":"petg","name":"Pet Games"}

suppose you want  id  of  this symbol: pal
i  thinked:  insert it in a for , and when i find a pal ,  call   id , but  not  work , anyone  can give me help ?? thanks

Allsymb =CGeckoCoinList()
?Allsymb
aLtSymb = Json2List(Allsymb)
//?mysee (aLtSymb,1)
//?aLtSymb[1][1][2][2]
//?type(aLtSymb[1][1][2][2])
CommAsset="zoc"
sCodeSymbol=""
?len(aLtSymb) =====>  why return 1?
for H=1 to len(aLtSymb)
?aLtSymb[1][H][:symbol]
if CommAsset = aLtSymb[1][H][:symbol]
sCodeSymbol = aLtSymb[1][H][:id]
ok
next
?sCodeSymbol




Ilir

unread,
Jul 20, 2022, 6:52:34 PMJul 20
to The Ring Programming Language
Hello Stefano,

?len(aLtSymb) =====>  why return 1?

because your JSON string begins with

[{

vs

{

For example:

{"symbol":"MKRUSDT","orderId":391551039,"orderListId":-1,"clientOrderId":"web_98b12738549b48f6aef63b91f543","price":"2899.00000000","origQty":"0.00590000","executedQty":"0.00000000","cummulativeQuoteQty":"0.00000000","status":"NEW","timeInForce":"GTC","type":"LIMIT","side":"SELL","stopPrice":"0.00000000","icebergQty":"0.00000000","time":1640336640527,"updateTime":1640336640527,"isWorking":true,"origQuoteOrderQty":"0.00000000"}

results in len = 18

while

[{"symbol":"MKRUSDT","orderId":391551039,"orderListId":-1,"clientOrderId":"web_98b12738549b48f6aef63b91f543","price":"2899.00000000","origQty":"0.00590000","executedQty":"0.00000000","cummulativeQuoteQty":"0.00000000","status":"NEW","timeInForce":"GTC","type":"LIMIT","side":"SELL","stopPrice":"0.00000000","icebergQty":"0.00000000","time":1640336640527,"updateTime":1640336640527,"isWorking":true,"origQuoteOrderQty":"0.00000000"}
]

results in len = 1

In case of len = 18, you access symbol using altSymb[:symbol]

In case of of len = 1, you access symbol using altSymbl[1][1][:symbol]

That's why I recommended to you to use startswith("{") check to concatenate

AllSymb = "[" + AllSymb + "]"

before a call to Json2List

in order to use altSymb[1][1][:symbol] in any case
Reply all
Reply to author
Forward
0 new messages