json problem

17 views
Skip to first unread message

stefano cerbioni

unread,
May 12, 2022, 3:58:25 PM5/12/22
to The Ring Programming Language
hi guys  i try to run this  function but  return me  error

Line 132 Error (R5) : Can't access the list item, Object is not list !
In function testjson() in file Terminal.ring
called from line 81  in file Terminal.ring

my function

testjson()
MsgInfo("demade 2","zero")

func testjson() {

jsonstring='{"symbol":"ETHBUSD","id":290133417,"orderId":4604755319,"orderListId":-1,"price":"2928.51000000","qty":"0.00680000","quoteQty":"19.91386800","commission":"0.00003727","commissionAsset":"BNB","time":1651737981325,"isBuyer":true,"isMaker":false,"isBestMatch":true},{"symbol":"ETHBUSD","id":290134760,"orderId":4604780032,"orderListId":-1,"price":"2934.02000000","qty":"0.00680000","quoteQty":"19.95133600","commission":"0.00003727","commissionAsset":"BNB","time":1651738539446,"isBuyer":true,"isMaker":false,"isBestMatch":true}]TC","id":524176,"orderId":6298853,"orderListId":-1,"price":"0.00000443","qty":"215.00000000","quoteQty":"0.00095245","commission":"0.00000095","commissionAsset":"BTC","time":1570617820073,"isBuyer":false,"isMaker":false,"isBestMatch":true},{"symbol":"PERLBTC","id":6353898,"orderId":66890243,"orderListId":-1,"price":"0.00000170","qty":"467.00000000","quoteQty":"0.00079390","commission":"0.00005418","commissionAsset":"BNB","time":1640191725974,"isBuyer":true,"isMaker":false,"isBestMatch":true},{"symbol":"PERLBTC","id":6360522,"orderId":66890259,"orderListId":-1,"price":"0.00000180","qty":"467.00000000","quoteQty":"0.00084060","commission":"0.00005838","commissionAsset":"BNB","time":1640554959821,"isBuyer":false,"isMaker":true,"isBestMatch":true},{"symbol":"PERLBTC","id":6392184,"orderId":67272762,"orderListId":-1,"price":"0.00000178","qty":"392.00000000","quoteQty":"0.00069776","commission":"0.00004647","commissionAsset":"BNB","time":1641211350289,"isBuyer":true,"isMaker":false,"isBestMatch":true},{"symbol":"PERLBTC","id":6395053,"orderId":67273054,"orderListId":-1,"price":"0.00000186","qty":"392.00000000","quoteQty":"0.00072912","commission":"0.00004952","commissionAsset":"BNB","time":1641370249824,"isBuyer":false,"isMaker":true,"isBestMatch":true}'
aList2 = Json2List(jsonstring)
//?aList
//mysee(aList,1)

symb = aList2[1][:symbol]
?symb



}

Ilir

unread,
May 12, 2022, 6:05:04 PM5/12/22
to The Ring Programming Language
Hello Stefano,

for the given jsonstring input, correct path is

? aList2[:symbol]

stefano cerbioni

unread,
May 14, 2022, 6:53:39 AM5/14/22
to Ilir, The Ring Programming Language
thanks at all
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "The Ring Programming Language" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ring-lang+...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ring-lang/1f669605-72fd-4377-ad67-66fc89977bd6n%40googlegroups.com.
>

stefano cerbioni

unread,
May 14, 2022, 6:53:39 AM5/14/22
to Ilir, The Ring Programming Language
i create the function testjson() for test if i call ?
aList2[:symbol] it must return 2 ETHBUSD ,and it work , but why
if i extract a json with function it return only a first ETHBUSD
and sencond jump out , i notice take only a first of double also
in other part of jason if find it example BTCUSDT and second
symbol is the same it jump a second symbol , why o_O




my function


func DwnldHistoryOrder(){ // funzione per scaricare da binance e
popolare il database da usare la prima volta

aSymbol = SelectDBinance ("Bin_ExchangeInfo_1","symbol",0,3)
aId= SelectDBinance ("HistoryOrder","idt",0,3)
//?type(aId)
//?aId
if len(aID) = 0 // se il db e' vuoto
for i=635 to len(aSymbol)
?"SONO A "+i +" totale da vedere sono "+len(aSymbol) +" sono al
symbol "+aSymbol[i][1]
zioT=MyTimeStamp()
//?zioT
ZioSg=BinSHA256Signature
("symbol="+aSymbol[i][1]+"&recvWindow=50000&timestamp="+zioT+";"+SecretKeyBin)
//?ZioSg
zio=BinApiAccountTradeList(""+ApiKeyBin+";"+aSymbol[i][1]+";0;0;0;0;0;50000;"+zioT+";"+ZioSg)
//?zio
//?Type(zio)

if substr(zio,"symbol")
if substr(zio,"{") =2 // se non e' vuoto
aList = Json2List(Zio)
// ?aList
//mysee(aList,1)

symb = aList[1][1][:symbol]
?symb
TransID = aList[1][1][:id]
OrdId = aList[1][1][:orderId]
OrdListID = aList[1][1][:orderListId]
Price = aList[1][1][:price]
OrgQt = aList[1][1][:qty]
QuoteQt = aList[1][1][:quoteQty]
Comms = aList[1][1][:commission]
CommAsset = aList[1][1][:commissionAsset]
Timestamp = aList[1][1][:time]
BuyOrSell = aList[1][1][:isBuyer]
TakerOrMaker = aList[1][1][:isMaker]
IsBestMatch = aList[1][1][:isBestMatch]


aLHistory=[symb,TransID,OrdId,OrdListID,Price,OrgQt,QuoteQt,Comms,CommAsset,Timestamp,BuyOrSell,TakerOrMaker,IsBestMatch,""]
// ?aLHistory

aColumnHistoryOrder=["symbol","TransID","orderId","orderListId","price","Qty","QuoteQty",

"Commission","CommissionAsset","timeStampTrans","IsBuyer","isMaker","IsBestMatch","Comment"]
// InsertInDBinace (
"HistoryOrder",aColumnHistoryOrder,aLHistory )

ok

ok

sleep(5)
next
else // il database history non e vuoto

ok

Mansour Ayouni

unread,
May 14, 2022, 6:53:39 AM5/14/22
to stefano cerbioni, The Ring Programming Language
Hello Stefano,

You've got a syntax error in the list.

load "jsonlib.ring"


cJSON ='

{ "symbol":"ETHBUSD",

},


{ "symbol":"ERROR",

? JSON2List(cJSON)


Here is a corrected version:
image.pnghe error is here exactly:
image.png


Best,

Mansour


--

---
You received this message because you are subscribed to the Google Groups "The Ring Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ring-lang+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages