json.net - Json to C# Object. Cant create proper class -


im trying deserialize json c# object newtonsoft's json library ,but cant create proper class it.i dont know why cant generate class json2sharp , etc. thats json data:

[130,18063676,[["i",{"currencypair":"xmr_blk","orderbook":[{"0.00229667":"22.10045806","0.00229668":"2.24052467","0.00230580":"0.66824024","0.00231496":"1.82565395","0.00231688":"0.69843078","0.00232910":"0.72274387","0.00233835":"1.91615041","0.00234029":"0.70761459","0.00235264":"0.78457456","0.00235612":"0.26512460","0.00236198":"1.99131201","0.00236394":"0.71414743","0.00236971":"2686.26872112","0.00237641":"0.80664194","0.00238585":"2.11842456","0.00238663":"99.74479966","0.00238783":"1.36311792","0.00240042":"0.67445439","0.00240996":"1.94689294","0.00241196":"0.59385108","0.00242070":"0.23867946","0.00242465":"0.05000000","0.00242468":"0.70267761","0.00243431":"1.45608290","0.00243633":"0.65598162","0.00244918":"0.46293261","0.00246095":"0.54877121","0.00248000":"1234.56780000","0.00249156":"49.32038060","0.00250000":"1000.45724850","0.00251625":"77.83042125","0.00251974":"0.09016889","0.00252588":"108.50204529","0.00253185":"242.63870683","0.00253290":"0.21717548","0.00258146":"1.71513682","0.00267206":"0.11116944","0.00268206":"0.21289550","0.00273751":"2.92888705","0.00280100":"7.00000000","0.00283058":"0.18656785","0.00284419":"0.22062485","0.00288632":"257.62211104","0.00289000":"208.79511523","0.00290299":"4.54689042","0.00291409":"0.15000000","0.00291640":"0.05000000","0.00291641":"0.05000000","0.00292941":"0.25000000","0.00293043":"0.50000000","0.00298996":"0.05000000","0.00299156":"0.30000000","0.00299869":"0.36250000","0.00300100":"3.00000000","0.00301925":"2.85164408","0.00303055":"0.05000000","0.00303592":"0.10000000","0.00303711":"0.06051986","0.00305172":"0.16044203","0.00306561":"265.98613244","0.00310000":"26.82852923","0.00312151":"0.11531956","0.00317022":"55.62770365","0.00317027":"0.06617082","0.00318552":"0.15716959","0.00320100":"3.00000000","0.00321764":"99.75000000","0.00325837":"0.10552478","0.00330927":"0.11200707","0.00332519":"0.33746733","0.00335915":"0.16121328","0.00340100":"3.00000000","0.00341163":"0.13788443","0.00342804":"0.34566265","0.00346305":"0.19119985","0.00348756":"10.27346000","0.00350000":"31.45516070","0.00351715":"0.14172408","0.00352135":"5.00000000","0.00353407":"0.39862518","0.00357017":"0.22406321","0.00362594":"0.16048029","0.00364338":"0.40571532","0.00366104":"68.61752578","0.00368060":"0.23118789","0.00368750":"7.47534500","0.00373809":"0.17956392","0.00375607":"0.47237418","0.00379444":"0.47907211","0.00380100":"3.00000000","0.00387368":"0.14830488","0.00389231":"0.41361341","0.00390000":"1086.65812559","0.00393207":"0.22554964","0.00395340":"6.23640000","0.00396000":"1.33263674","0.00400000":"861.36424252","0.00401835":"0.74479806","0.00403768":"0.84085154","0.00407560":"7.34530000","0.00407892":"2.93798934","0.00424540":"5.45754000","0.00429312":"0.85462183","0.00431377":"1.02379072","0.00434391":"4.09559109","0.00448670":"6.43450000","0.00452135":"5.00000000","0.00456716":"1.27494102","0.00458913":"1.31893393","0.00459674":"5.81307351","0.00460000":"5.00000000","0.00462300":"541.00099775","0.00469450":"7.56753000","0.00478000":"80.28917709","0.00480000":"348.20000000","0.00485623":"1.57196462","0.00485869":"4.31681492","0.00486429":"5.58910584","0.00488740":"6.46740000","0.00490000":"3.00000000","0.00500000":"17.35633213","0.00509543":"5.05467000","0.00513888":"3.02645787","0.00514148":"5.03326419","0.00514741":"12.41074031","0.00515000":"10017.00000000","0.00527570":"5.05670000","0.00540000":"2.00000000","0.00543798":"1.16254591","0.00544073":"2.04827679","0.00544701":"4.94262448","0.00547860":"6.24740000","0.00548800":"2.00000000","0.00552135":"5.00000000","0.00568744":"7.74534000","0.00569000":"10.54481546","0.00576350":"1.96469354","0.00577015":"4.53722308","0.00578510":"1.03693487","0.00588394":"7.20627839","0.00588740":"7.45600000","0.00588800":"1.00000000","0.00598800":"1.00000000","0.00600000":"398.32786857","0.00609768":"5.04343670","0.00616416":"7.20627839","0.00616418":"0.77985772","0.00617129":"3.33704064","0.00618728":"1.35702493","0.00622801":"0.67897320","0.00623906":"0.77163865","0.00624626":"3.99974754","0.00626244":"1.39440606","0.00630000":"35.00000000","0.00630209":"0.88683339","0.00630936":"5.62758725","0.00632571":"1.93131866","0.00636576":"1.48357895","0.00637310":"7.60288981","0.00637649":"8.14339607","0.00638962":"2.12344370","0.00639564":"1.70809755","0.00639754":"1.96648654","0.00643007":"1.05513568","0.00645615":"2.96517668","0.00645705":"5.97278720","0.00645965":"1.94587971","0.00647379":"1.97248472","0.00648768":"1.32450000","0.00650000":"59.98500000","0.00650771":"7.20627839","0.00652135":"5.00000000","0.00652176":"1.96648661","0.00653000":"110.04350000","0.00656000":"20.00000000","0.00659542":"6.00000000","0.00661000":"10.00000000","0.00661398":"4.05360501","0.00664570":"7.56000000","0.00666000":"21.90307814","0.00666173":"4.40295148","0.00667021":"1.06107702","0.00669819":"5.77696118","0.00671556":"1.72044063","0.00672769":"4.40295148","0.00675300":"15.00000000","0.00679364":"4.40295148","0.00685960":"4.40295148","0.00688560":"1.30512280","0.00690000":"50.00000000","0.00691214":"1.07609877","0.00692298":"36.00000000","0.00692556":"4.40295148","0.00694834":"5.16486770","0.00695914":"240.70466273","0.00695954":"6.00000000","0.00697530":"15.00000000","0.00699202":"1.66176545","0.00705993":"1.48172707","0.00708700":"2.90881521","0.00710000":"15.00000000","0.00712983":"1.48172707","0.00716285":"0.44291883","0.00719973":"1.48172707","0.00720036":"2.43432481","0.00720879":"100.08583662","0.00721155":"0.61693611","0.00726456":"0.44725112","0.00726963":"1.48172707","0.00728782":"2.71244118","0.00730000":"50.00000000","0.00731000":"15.00000000","0.00731396":"0.60512986","0.00732687":"1.22884288","0.00733953":"1.48172708","0.00733960":"300.00000000","0.00735259":"2.07956105","0.00735341":"0.71380442","0.00735605":"0.53226805","0.00736025":"0.52470413","0.00736551":"0.77097125","0.00737307":"0.36657420","0.00737475":"3.66705930","0.00737635":"2.99429959","0.00739350":"2.17615307","0.00739573":"2.60854878","0.00739731":"1.22884292","0.00740615":"0.02398988","0.00741782":"0.68269958","0.00742127":"1.54798545","0.00742410":"0.71380446","0.00742676":"0.53226809","0.00743007":"2.52187210","0.00743633":"0.77097126","0.00743728":"0.64447712","0.00744396":"0.36657423","0.00744564":"3.66705934","0.00745720":"0.57338303","0.00746595":"3.29950328","0.00746685":"2.60854879","0.00748970":"8.59578400","0.00749264":"1.54798545","0.00750000":"97.52743449","0.00750950":"0.64447712","0.00752135":"5.00000000","0.00752315":"0.71705582","0.00754778":"0.61810761","0.00755664":"3.53968783","0.00758171":"0.64447713","0.00763100":"15.00000000","0.00763946":"0.68477511","0.00764285":"10.00000000","0.00765569":"1351.95460075","0.00765600":"23.82568625","0.00766100":"9.15686275","0.00766395":"3.35329190","0.00768434":"7.84560000","0.00769595":"6.00000000","0.00770000":"68.70019724","0.00773226":"0.80774511","0.00777278":"3.77858515","0.00777777":"990.89110098","0.00782618":"0.98911342","0.00783744":"1794.31986586","0.00785000":"152.63004030","0.00785960":"9.53740000","0.00788315":"4.02896933","0.00793731":"0.95718358","0.00796310":"15.00000000","0.00796959":"6.00000000","0.00799509":"7.53854751","0.00800000":"350.85610303","0.00805002":"1.08128391","0.00808300":"496.39983125","0.00810000":"65.00000000","0.00811535":"14.45293785","0.00811989":"0.00595451","0.00816433":"1.49496735","0.00816660":"5.52203767","0.00820387":"460.06364638","0.00821434":"38.85548776","0.00824950":"7.90954937","0.00825744":"6.76158731","0.00827854":"5.83678779","0.00828026":"0.69329340","0.00828916":"0.37534076","0.00829000":"28.00146914","0.00829300":"63896.50669264","0.00830000":"520.48192771","0.00831000":"15.00000000","0.00831288":"1.50419508","0.00835774":"6.85021563","0.00840000":"119.04761904","0.00841202":"399.04052396","0.00845236":"565.63882911","0.00845926":"1.17561923","0.00848663":"14.36942888","0.00849586":"8.75670000","0.00850000":"167.64705882","0.00850529":"1.45304978","0.00857171":"0.38933423","0.00858740":"6.10814648","0.00860000":"116.27906976","0.00860548":"1.28683076","0.00863100":"15.00000000","0.00870000":"114.94252873","0.00873170":"100.00000000","0.00875701":"1.30712959","0.00879000":"187.63016831","0.00879088":"116.00000000","0.00879695":"6.00000000","0.00880000":"515.63636363","0.00880001":"17.60687230","0.00882910":"1.63681044","0.00885126":"65.00000000","0.00887342":"0.31781450","0.00887850":"2.86550000","0.00888130":"1.94320811","0.00888150":"15.30355171","0.00888880":"90.84767503","0.00890000":"162.35955056","0.00896310":"15.00000000","0.00900000":"1666.36500369","0.00900126":"25.00000000","0.00902989":"1.56002337","0.00910000":"109.89010989","0.00910171":"414.07152978","0.00920000":"108.69565217","0.00921804":"333.00000000","0.00929542":"528.99090493","0.00930000":"157.52688172","0.00933000":"427.32301746","0.00940000":"106.38297872","0.00948760":"8.78564000","0.00950000":"105.26315789","0.00952135":"5.00000000","0.00952263":"50.00000000","0.00960000":"104.16666666","0.00967627":"1.33678031","0.00969595":"6.10814648","0.00970000":"103.09278350","0.00979658":"330.00000000","0.00980000":"102.04081632","0.00980490":"0.43677908","0.00985700":"2.00000000","0.00987969":"5.99633843","0.00989674":"2.74563000","0.00990000":"101.01010101","0.00991000":"15880.64250868","0.00992120":"438.12705103","0.00997779":"1.75730618","0.01000000":"215.99500625","0.01010000":"99.00990099","0.01020000":"98.03921568","0.01030000":"97.08737864","0.01040000":"96.15384615","0.01048956":"8.74345000","0.01050000":"95.23809523","0.01059572":"325.95207264","0.01060000":"94.33962264","0.01069202":"1.39154562","0.01070000":"93.45794392","0.01079000":"2.98535000","0.01080000":"92.59259259","0.01083415":"0.45340897","0.01086000":"33.01620583","0.01089850":"2.83445000","0.01099492":"12.21629296","0.01100000":"456.86935122","0.01102519":"2.41781317","0.01148487":"209.45414745","0.01148785":"8.46450000","0.01157537":"442.67446426","0.01181440":"2.44353480","0.01185700":"2.00000000","0.01186000":"70.00000000","0.01189670":"2.85645000","0.01197145":"0.69684899","0.01218254":"2.59956533","0.01234980":"344.92682456","0.01244000":"224.00000000","0.01245236":"500.00000000","0.01248670":"7.64534000","0.01278950":"2.75463000","0.01299330":"664.74346385","0.01299518":"6.10814648","0.01300000":"26.14634015","0.01305460":"2.63148534","0.01322813":"0.81989766","0.01330000":"59.85000000","0.01347574":"3.00000000","0.01348795":"7.58485000","0.01352135":"5.00000000","0.01385782":"1122.47921946","0.01399780":"2.74743400","0.01416643":"780.97652730","0.01442498":"3.91128602","0.01457450":"7.45630000","0.01460000":"500.25659354","0.01461673":"0.86053066","0.01487446":"2.40841162","0.01487680":"2.47570000","0.01490000":"359.49307130","0.01496804":"5.02391716","0.01499991":"35627.78290763","0.01500001":"53620.71957921","0.01501427":"32153.24270152","0.01502411":"18769.84433720","0.01512411":"26587.76728056","0.01522421":"965.65121963","0.01547574":"3.00000000","0.01553764":"7.47450000","0.01559910":"444.50306311","0.01585000":"1.18000000","0.01585700":"2.00000000","0.01589670":"3.54646000","0.01593922":"3.73750978","0.01600000":"19.66779705","0.01615109":"0.85424380","0.01623222":"4.00000000","0.01649860":"7.85685600","0.01652263":"50.00000000","0.01687456":"2.13245000","0.01721943":"1249.39868463","0.01747574":"3.00000000","0.01748876":"3.84755000","0.01752135":"5.00000000","0.01763499":"40.00000000","0.01769056":"222.90722050","0.01771026":"4.09100407","0.01785000":"1.65000000","0.01789850":"3.23440000","0.01794567":"0.93218628","0.01836356":"2.26718172","0.01848345":"0.96667613","0.01855940":"2.50000000","0.01857870":"3.74567400","0.01880046":"519.22000000","0.01887840":"0.37478926","0.01900000":"289.27500000","0.01900003":"2.99000000","0.01947574":"3.00000000","0.01948870":"3.05670000","0.01967808":"4.29307058","0.01974468":"155.54450638","0.01985700":"2.00000000","0.01989640":"3.27567000","0.02048750":"7.85684500","0.02055940":"2.80000000","0.02084850":"2.46653000","0.02088998":"1.00000000","0.02147574":"3.00000000","0.02155940":"3.20000000","0.02186454":"4.18708489","0.02188998":"1.00000000","0.02287600":"2.32455000","0.02313906":"1.20544514","0.02347574":"3.00000000","0.02426782":"3.48000000","0.02429395":"3.79222177","0.02488778":"1.65785734","0.02548920":"5.11258841","0.02553138":"4.00000000","0.02687970":"2.17547000","0.02699329":"3.90504446","0.02747574":"2.47000000","0.02752135":"5.00000000","0.02800000":"11.45549490","0.02886780":"1.80637441","0.02963864":"2.73294238","0.03105389":"3.50000000","0.03142188":"0.59212958","0.03171335":"5.12116076","0.03230000":"0.04987500","0.03234763":"4.66381128","0.03286580":"2.47567000","0.03433946":"3.00000000","0.03468676":"1.81710545","0.03487865":"2.46364000","0.03538051":"1.71297166","0.03626086":"1.01045837","0.03666666":"110.22969551","0.03672498":"1.26544297","0.03745949":"1.57691042","0.03752135":"5.00000000","0.03786780":"2.19021650","0.03900000":"10.00000000","0.04030642":"1.27916410","0.04135440":"0.70097846","0.04485600":"1.74550000","0.04666666":"136.95641473","0.04845600":"1.78810800","0.05000000":"15.53608644","0.05433946":"3.00000000","0.05488750":"7.67800000","0.05666666":"0.77374524","0.05752135":"5.00000000","0.05856745":"8.74574700","0.06013189":"30.00000000","0.06037434":"1.20796272","0.06485680":"9.66760000","0.06666666":"0.85971694","0.06725702":"0.27484817","0.06895464":"10.85674560","0.07000000":"5.80970714","0.07433946":"3.00000000","0.07496700":"9.85645000","0.07752135":"5.00000000","0.07896757":"11.74575400","0.08489786":"12.76574000","0.08802941":"200.00000000","0.08802942":"1200.00000000","0.08886470":"10.56754630","0.09433946":"3.00000000","0.09475480":"10.24574570","0.09878760":"8.85687000","0.10000000":"6.00000000","0.10236135":"3.60045582","0.10895467":"7.85654760","0.12856000":"6.78547450","0.14339460":"3.00000000","0.14856750":"4.74574500","0.16666666":"0.95524105","0.18580000":"3.97411460","0.23023199":"5.00000000","0.23023200":"2936.92260841","0.26666666":"1.06137894","0.34339460":"3.00000000","0.36666666":"1.17930993","0.43401216":"347.48562982","0.46666666":"1.31034437","0.54610600":"3.60000000","0.56666666":"1.45593819","0.66666666":"1.61770910","0.76666666":"1.79745456","0.86666665":"200.00000000","0.86666666":"301.99717173","0.87666666":"2.21907970","0.87966666":"2.46564411","0.87996666":"2.73960457","0.87999666":"3.04400507","0.99999998":"1.56830975","1.00000000":"4883.62583027","2.00000000":"133.13949211","2.09266630":"1.34755532","2.99999666":"8.09060055","2.99999998":"1.39695867","9.00000000":"100.00000000","10.00000000":"6.10000000","998.00000000":"100.00000000","999.00000000":"5.00000000"},{"0.00229138":"38.10287686","0.00227997":"7.20868129","0.00217907":"0.25992533","0.00217880":"7.73820000","0.00217785":"0.93328858","0.00217604":"5.89965342","0.00216743":"1.66159614","0.00215885":"0.05500000","0.00215082":"0.11000000","0.00214977":"0.05500000","0.00214273":"0.05500000","0.00214099":"0.05500000","0.00214046":"0.05500000","0.00213995":"6.03084184","0.00213993":"0.05500000","0.00213899":"18.65815174","0.00213752":"0.05500000","0.00213694":"0.05500000","0.00213556":"0.22000000","0.00212801":"0.05500000","0.00212357":"0.05500000","0.00212318":"0.05500000","0.00212252":"0.05500000","0.00212178":"0.05500000","0.00211765":"0.05500000","0.00211702":"0.05500000","0.00211701":"0.05500000","0.00211516":"0.05500000","0.00211139":"0.05500000","0.00211137":"0.05500000","0.00211118":"0.05500000","0.00211029":"0.11000000","0.00210769":"0.11000000","0.00210753":"0.16500000","0.00210724":"0.05500000","0.00210676":"0.05500000","0.00210607":"0.11000000","0.00210522":"0.11000000","0.00210407":"0.11000000","0.00210398":"0.11000000","0.00210300":"0.05500000","0.00210248":"0.11000000","0.00209091":"0.05500000","0.00206181":"0.05500000","0.00206173":"0.05500000","0.00205796":"0.05500000","0.00205740":"0.05500000","0.00204882":"0.05500000","0.00203811":"0.05500000","0.00203222":"1.75484097","0.00202450":"7.57330205","0.00199618":"0.05500000","0.00199617":"0.05500000","0.00196735":"0.05500000","0.00196105":"0.05500000","0.00195227":"0.05500000","0.00193534":"0.05500000","0.00193533":"0.05500000","0.00193532":"0.11000000","0.00191740":"0.05500000","0.00188504":"0.33000000","0.00187707":"0.05500000","0.00187469":"0.05500000","0.00187466":"166.85951847","0.00186029":"0.29134534","0.00185901":"13.39935428","0.00183710":"272.16808557","0.00183682":"50.01300819","0.00180000":"114.99999999","0.00178943":"465.94992831","0.00177007":"100.00000000","0.00175029":"0.81162956","0.00175026":"364.67284600","0.00173936":"40.00000000","0.00166600":"15.00600240","0.00156660":"31.91625175","0.00150007":"100.00000000","0.00150002":"100.00000000","0.00147507":"100.00000000","0.00146617":"500.00000000","0.00139100":"65.00000000","0.00110000":"9.09090909","0.00102337":"100.00000000","0.00102330":"232.64500000","0.00100007":"2000.00000000","0.00100000":"89999.99999000","0.00049173":"500.00000000","0.00049172":"6101.03310827","0.00039000":"127.82000000","0.00012871":"500.00000000","0.00003517":"1000.00000000","0.00003508":"3000.00000000","0.00003507":"7585.43632594","0.00001288":"1000.00000000","0.00001287":"23310.02331002","0.00000222":"10000.00000000","0.00000200":"10000.00000000","0.00000137":"7777.00000000","0.00000130":"10000.00000000","0.00000129":"232558.13953488","0.00000100":"7300.00000000","0.00000017":"3000.00000000","0.00000011":"100000.00000000","0.00000010":"73000.00000000","0.00000003":"100000.00000000","0.00000002":"50000000.00000000","0.00000001":"1972363.00000000"}]}]]] 

thats have: https://ybin.me/p/a825152ddcde634a#jrwwc5ww2ba2bkiweblley4+sj0vpps9kszu21bjqus= im adding external link because of limit of message in here. , error is:

an unhandled exception of type 'newtonsoft.json.jsonserializationexception' occurred in newtonsoft.json.dll

cannot deserialize current json array (e.g. [1,2,3]) type 'masterdata' because type requires json object (e.g. {"name":"value"}) deserialize correctly.

to fix error either change json json object (e.g. {"name":"value"}) or change deserialized type array or type implements collection interface (e.g. icollection, ilist) list can deserialized json array. jsonarrayattribute can added type force deserialize json array.

path '', line 1, position 1.

edit: thank answers.after inital data feed uses different format.

[132,36988065,[["o",1,"2.84200012","0.00000000"],["o",1,"2.84200014","0.29990442"]]] 

here class have tried create, im getting same exception error stated above.

public class small         {             public int id { get; set; }             public long seq { get; set; }             public innerobjectsmall obj { get; set; }         }         public class innerobjectsmall         {             public string id { get; set; }             public int ordertype { get; set; }             public list<dictionary<decimal, decimal>> orderbook { get; set; }         } 

you have create custom jsonconverters achieve this. based on data, , without knowledge of logic behind data came :

class program {      static void main(string[] args)     {         var value = jsonconvert.deserializeobject<masterdata>(beginingdataraw);     } }  [jsonconverter(typeof(masterdataconverter))] public class masterdata {     public int id { get; set; }     public long seq { get; set; }     public list<innerobjects> obj { get; set; } }  [jsonconverter(typeof(innerobjectsconverter))] public class innerobjects {     public string id { get; set; }     public orderdata data { get; set; }  }  public class orderdata {     public string currencypair { get; set; }     public list<dictionary<string, string>> orderbook { get; set; } }  class innerobjectsconverter : jsonconverter {     public override bool canconvert(type objecttype)     {         return objecttype == typeof(innerobjects);     }      public override object readjson(jsonreader reader, type objecttype, object existingvalue, jsonserializer serializer)     {         var value = new innerobjects();         value.id = reader.readasstring();         reader.read();         value.data = serializer.deserialize<orderdata>(reader);         reader.read();         return value;     }      public override void writejson(jsonwriter writer, object value, jsonserializer serializer)     {         throw new notimplementedexception();     } } class masterdataconverter : jsonconverter {     public override bool canconvert(type objecttype)     {         return true;     }      public override object readjson(jsonreader reader, type objecttype, object existingvalue, jsonserializer serializer)     {         if (reader.tokentype == jsontoken.startarray)         {             var value = new masterdata             {                 id = (int)reader.readasint32(),                 seq = (long)(decimal)reader.readasdecimal()             };             reader.read();             value.obj = serializer.deserialize<list<innerobjects>>(reader);             reader.read();             return value;         }         return null;     }      public override void writejson(jsonwriter writer, object value, jsonserializer serializer)     {         throw new notimplementedexception();     } } 

some handling invalid data should added should started.


Comments