B4J Question Question about json generator and order of map

tufanv

Expert
Licensed User
Longtime User
hello,

I am having a problem with generating json and maps.
my code is :
dim sayi as int=-1
B4X:
Do While cursor.NextRow
    sayi=sayi+1
    n = CreateMap("coin":cursor.GetString("sembol"),"last" :cursor.GetString("last"),"change": cursor.GetString("changenumber"))
'm.Put(cursor.GetString("sembol"),cursor.GetString("sembol"))
'm.Put(cursor.GetString("last"),cursor.GetString("last"))
m.Put(sayi,n)
Loop
Dim jsong As JSONGenerator
jsong.Initialize(m)

As I understand, this should put to map with the order of int "sayi" like 0,1,2,3 but it is not. When I look at the generated json I see:

B4X:
{"88":{"last":"22.39015","change":"0.10465","coin":"USD\/CSK"},"89":{"last":"118.99","change":"0.18","coin":"USD\/DZD"},"110":{"last":"165.01","change":"-1.63","coin":"SG18BIL"},"111":{"last":"206.14","change":"-2.05","coin":"SG22BIL"},"90":{"last":"17.91505","change":"0.0221","coin":"USD\/EGP"},"91":{"last":"2.66495","change":"0","coin":"USD\/GEL"},"92":{"last":"4.905","change":"0.025","coin":"USD\/GHS"},"93":{"last":"6.50675","change":"0.0245","coin":"USD\/HRK"},"94":{"last":"3.67665","change":"0.0131","coin":"USD\/ILS"},"95":{"last":"121.195","change":"0.545","coin":"USD\/ISK"},"96":{"last":"0.7085","change":"-0.0005","coin":"USD\/JOD"},"97":{"last":"1509.205","change":"0.02","coin":"USD\/LBP"},"10":{"last":"1.5152","change":"-0.0074","coin":"EUR\/CAD"},"98":{"last":"182.255","change":"0.005","coin":"USD\/LKR"},"11":{"last":"9.76675","change":"-0.03725","coin":"EUR\/NOK"},"99":{"last":"3.342","change":"-0.001","coin":"USD\/PEN"},"12":{"last":"10.2435","change":"-0.0227","coin":"EUR\/SEK"},"13":{"last":"1.6749","change":"-0.0069","coin":"EUR\/NZD"},"14":{"last":"8.9746","change":"0.0236","coin":"USD\/SEK"},"15":{"last":"8.55655","change":"0.0086","coin":"USD\/NOK"},"16":{"last":"13.8354","change":"0.05635","coin":"USD\/ZAR"},"17":{"last":"108.35","change":"0.145","coin":"USD\/JPY"},"18":{"last":"1.32755","change":"0","coin":"USD\/CAD"},"19":{"last":"0.9867","change":"0.00555","coin":"USD\/CHF"},"0":{"last":"5.4487","change":"-0.00155","coin":"USD\/TRL"},"1":{"last":"6.2227","change":"-0.0321","coin":"EUR\/TRL"},"2":{"last":"19.8705","change":"0.0315","coin":"TRL\/JPY"},"3":{"last":"5.5227","change":"-0.03225","coin":"CHF\/TRL"},"4":{"last":"7.0048","change":"-0.01305","coin":"GBP\/TRL"},"5":{"last":"1.14143","change":"-0.00551","coin":"EUR\/USD"},"6":{"last":"123.6665","change":"-0.435","coin":"EUR\/JPY"},"7":{"last":"0.8884","change":"-0.00295","coin":"EUR\/GBP"},"8":{"last":"1.1262","change":"0.0008","coin":"EUR\/CHF"},"9":{"last":"1.58785","change":"-0.00575","coin":"EUR\/AUD"},"20":{"last":"7.8424","change":"-0.0001","coin":"USD\/HKD"},"21":{"last":"1120.745","change":"-2.175","coin":"USD\/KRW"},"22":{"last":"6.7695","change":"0.006","coin":"USD\/CNH"},"23":{"last":"19.042","change":"0.025","coin":"USD\/MXN"},"24":{"last":"1.05486","change":"-0.00043","coin":"AUD\/NZD"},"25":{"last":"0.7189","change":"-0.00095","coin":"AUD\/USD"},"26":{"last":"0.9543","change":"-0.0012","coin":"AUD\/CAD"},"27":{"last":"0.70925","change":"0.0031","coin":"AUD\/CHF"},"28":{"last":"77.88","change":"0.005","coin":"AUD\/JPY"},"29":{"last":"1.28485","change":"-0.002","coin":"GBP\/USD"},"30":{"last":"1.78735","change":"-0.0005","coin":"GBP\/AUD"},"31":{"last":"1.70565","change":"-0.00255","coin":"GBP\/CAD"},"32":{"last":"139.205","change":"-0.035","coin":"GBP\/JPY"},"33":{"last":"1.88535","change":"-0.00145","coin":"GBP\/NZD"},"34":{"last":"0.7432","change":"0.0041","coin":"CAD\/CHF"},"35":{"last":"81.6155","change":"0.107","coin":"CAD\/JPY"},"36":{"last":"0.68147","change":"-0.00057","coin":"NZD\/USD"},"37":{"last":"109.815","change":"-0.465","coin":"CHF\/JPY"},"38":{"last":"802","change":"0.44","coin":"XPT\/USD"},"39":{"last":"702.225","change":"3.4","coin":"XPT\/EUR"},"40":{"last":"1130.87","change":"4.73","coin":"XAU\/EUR"},"41":{"last":"13.645","change":"0.01","coin":"XAG\/EUR"},"42":{"last":"7.46375","change":"-0.00015","coin":"EUR\/DKK"},"43":{"last":"6.5393","change":"0.0317","coin":"USD\/DKK"},"44":{"last":"7.7167","change":"-0.04565","coin":"EUR\/CNY"},"45":{"last":"6.76025","change":"-0.0078","coin":"USD\/CNY"},"46":{"last":"76.5825","change":"-0.2695","coin":"EUR\/RUB"},"47":{"last":"67.09925","change":"0.10155","coin":"USD\/RUB"},"48":{"last":"3.751","change":"0","coin":"USD\/SAR"},"49":{"last":"4.28125","change":"-0.0211","coin":"EUR\/SAR"},"50":{"last":"3.67295","change":"-0.00005","coin":"USD\/AED"},"51":{"last":"4.19525","change":"-0.0164","coin":"EUR\/AED"},"52":{"last":"674.815","change":"1.33","coin":"USD\/CLP"},"53":{"last":"770.285","change":"-1.89","coin":"EUR\/CLP"},"54":{"last":"3.7617","change":"0.0204","coin":"USD\/PLN"},"55":{"last":"4.29355","change":"0.0029","coin":"EUR\/PLN"},"56":{"last":"1.3542","change":"0.00035","coin":"USD\/SGD"},"57":{"last":"4.23695","change":"-0.0042","coin":"EUR\/BRL"},"58":{"last":"3.71075","change":"0.012","coin":"USD\/BRL"},"59":{"last":"15.79125","change":"-0.0128","coin":"EUR\/ZAR"},"60":{"last":"30.88","change":"0.02","coin":"USD\/TWD"},"61":{"last":"42025","change":"0","coin":"USD\/IRR"},"62":{"last":"1.9561","change":"0.00035","coin":"EUR\/BGN"},"63":{"last":"1280.525","change":"-5.54","coin":"EUR\/KRW"},"64":{"last":"17.7764","change":"0.0454","coin":"GBP\/ZAR"},"65":{"last":"1290.865","change":"-0.79","coin":"XAU\/USD"},"66":{"last":"15.58","change":"-0.055","coin":"XAG\/USD"},"67":{"last":"0.30385","change":"0.0003","coin":"USD\/KWD"},"68":{"last":"138.75","change":"-0.005","coin":"USD\/PKR"},"69":{"last":"4.10275","change":"0.023","coin":"USD\/RON"},"70":{"last":"20114","change":"-111","coin":"BTC\/TRY"},"71":{"last":"1795.575","change":"0.99","coin":"XAU\/AUD"},"72":{"last":"3.6405","change":"-0.00015","coin":"USD\/QAR"},"73":{"last":"73.8335","change":"0.037","coin":"NZD\/JPY"},"74":{"last":"3.0907","change":"0.01745","coin":"CAD\/RON"},"75":{"last":"8.67275","change":"-0.0394","coin":"CHF\/NOK"},"76":{"last":"4.15865","change":"0.0005","coin":"CHF\/RON"},"77":{"last":"1.2675","change":"0.0049","coin":"GBP\/CHF"},"78":{"last":"5.27045","change":"0.02145","coin":"GBP\/RON"},"79":{"last":"1.04885","change":"0.0017","coin":"NOK\/SEK"},"100":{"last":"0.39","change":"0","coin":"USD\/OMR"},"101":{"last":"32.835","change":"0.005","coin":"USD\/UYU"},"102":{"last":"8354.875","change":"1.125","coin":"USD\/UZS"},"103":{"last":"31.8975","change":"-0.015","coin":"USD\/THB"},"104":{"last":"71.085","change":"0.3045","coin":"USD\/INR"},"105":{"last":"225.887","change":"-0.481","coin":"XGLD"},"106":{"last":"369.57","change":"-3.66","coin":"SGCEYREK"},"80":{"last":"0.90467","change":"-0.00069","coin":"NZD\/CAD"},"107":{"last":"739.13","change":"-7.34","coin":"SGYARIM"},"81":{"last":"0.67233","change":"0.00316","coin":"NZD\/CHF"},"108":{"last":"1520","change":"-15","coin":"SCUM"},"82":{"last":"0.59705","change":"0.00245","coin":"NZD\/EUR"},"109":{"last":"128.84","change":"-1.28","coin":"SG14BIL"},"83":{"last":"36.9435","change":"-0.0065","coin":"USD\/ARS"},"84":{"last":"1.7","change":"0","coin":"USD\/AZN"},"85":{"last":"1.71595","change":"0.0066","coin":"USD\/BAM"},"86":{"last":"0.375","change":"0","coin":"USD\/BHD"},"87":{"last":"604.665","change":"-0.575","coin":"USD\/CRC"}}

why isn't this is ordered ? What am i doing wrong here ?
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0
Top