why my C# json Deserialization failed? -


i fighting against decoding json file popular historical methods mentioned in stackoverflow.com site. however, none of them worked in case. here little piece of json file dealing with:

[{     "lat": [ [-19.1415329], [-18.822279], [-18.672287]     ],     "lon": [ [135.673416], [135.547226], [135.566849]     ] }] 

you can see complete json file here: ftp://ftp.star.nesdis.noaa.gov/pub/smcd/spb/xjin/icvs/json/npp/2016/20160124_cris.fsr.json

using system.net; using system.io; using system.runtime.serialization; using system.runtime.serialization.json; using system.web.script.serialization;  string jsonftp = @"ftp://ftp.star.nesdis.noaa.gov/pub/smcd/spb/xjin/icvs/json/npp/2016/20160124_cris.fsr.json"; getjson(jsonftp);  private void getjson(string url) {     var req = (ftpwebrequest)webrequest.create(url);     using (stream stream = req.getresponse().getresponsestream())     {         streamreader reader = new streamreader(stream);         string jsontext = reader.readtoend();         javascriptserializer ojs = new javascriptserializer();         rootobject orootobject = new rootobject();         orootobject = ojs.deserialize<rootobject>(jsontext);         messagebox.show("ok");     } }      public class rootobject     {         public list<list<double>> lat { get; set; }         public list<list<double>> lon { get; set; }         public list<list<int>> bt900 { get; set; }         public list<list<int>> bt2500 { get; set; }         public list<list<int>> bt1030 { get; set; }         public list<list<int>> bt1500 { get; set; }         public list<list<double>> irad900 { get; set; }         public list<list<double>> irad2500 { get; set; }         public list<list<int>> overallqflw { get; set; }         public list<list<int>> overallqfmw { get; set; }         public list<list<int>> overallqfsw { get; set; }         public list<list<int>> fov { get; set; }         public list<list<int>> { get; set; }         public list<list<int>> scan { get; set; }         public list<list<int>> qf11 { get; set; }         public list<list<int>> qf12 { get; set; }         public list<list<int>> qf13 { get; set; }         public list<list<int>> qf14 { get; set; }         public list<list<int>> qf15 { get; set; }         public list<list<int>> qf16 { get; set; }         public list<list<int>> qf2lw { get; set; }         public list<list<int>> qf2mw { get; set; }         public list<list<int>> qf2sw { get; set; }         public list<list<int>> qf32lw { get; set; }         public list<list<int>> qf32mw { get; set; }         public list<list<int>> qf32sw { get; set; }         public list<list<int>> qf33lw { get; set; }         public list<list<int>> qf33mw { get; set; }         public list<list<int>> qf33sw { get; set; }         public list<list<int>> qf34lw { get; set; }         public list<list<int>> qf34mw { get; set; }         public list<list<int>> qf34sw { get; set; }         public list<list<int>> qf35lw { get; set; }         public list<list<int>> qf35mw { get; set; }         public list<list<int>> qf35sw { get; set; }         public list<list<int>> qf41lw { get; set; }         public list<list<int>> qf41mw { get; set; }         public list<list<int>> qf41sw { get; set; }         public list<list<int>> qf42lw { get; set; }         public list<list<int>> qf42mw { get; set; }         public list<list<int>> qf42sw { get; set; }         public list<list<int>> qf43lw { get; set; }         public list<list<int>> qf43mw { get; set; }         public list<list<int>> qf43sw { get; set; }         public list<list<int>> qf44lw { get; set; }         public list<list<int>> qf44mw { get; set; }         public list<list<int>> qf44sw { get; set; }         public list<list<int>> qf45lw { get; set; }         public list<list<int>> qf45mw { get; set; }         public list<list<int>> qf45sw { get; set; }         public list<list<int>> dswsizelw { get; set; }         public list<list<int>> dswsizemw { get; set; }         public list<list<int>> dswsizesw { get; set; }         public list<list<int>> itwsizelw { get; set; }         public list<list<int>> itwsizemw { get; set; }         public list<list<int>> itwsizesw { get; set; }         public list<list<int>> prttemps { get; set; }         public list<list<int>> impulsenoiselw { get; set; }         public list<list<int>> impulsenoisemw { get; set; }         public list<list<int>> impulsenoisesw { get; set; }         public list<list<int>> zpdfclw { get; set; }         public list<list<int>> zpdfcmw { get; set; }         public list<list<int>> zpdfcsw { get; set; }         public list<list<int>> sdrfclw { get; set; }         public list<list<int>> sdrfcmw { get; set; }         public list<list<int>> sdrfcsw { get; set; }         public list<list<int>> zpdmglw { get; set; }         public list<list<int>> zpdmgmw { get; set; }         public list<list<int>> zpdmgsw { get; set; }         public list<list<double>> dssymmetrylw { get; set; }         public list<list<double>> dssymmetrymw { get; set; }         public list<list<double>> dssymmetrysw { get; set; }         public list<list<double>> dsspcstablw { get; set; }         public list<list<double>> dsspcstabmw { get; set; }         public list<list<double>> dsspcstabsw { get; set; }         public list<list<double>> itspcstablw { get; set; }         public list<list<double>> itspcstabmw { get; set; }         public list<list<double>> itspcstabsw { get; set; }         public list<list<double>> ittempstab { get; set; }         public list<list<double>> ittempcons { get; set; }         public list<list<double>> mealaserwl { get; set; }         public list<list<double>> monlaserwl { get; set; }         public list<list<double>> reslaserwl { get; set; }         public list<string> maneuver { get; set; }         public list<string> v { get; set; }         public list<string> granuleid { get; set; }     } 

the program never reaches end, say, calling messagebox. can see content corrected loaded jsontext under debug mode.but orootobject null.

i tried method using json.net still didn't work.

private void getjson(string url) {     var req = (ftpwebrequest)webrequest.create(url);     using (stream stream = req.getresponse().getresponsestream())     {         streamreader reader = new streamreader(stream);         string jsontext = reader.readtoend();          var serializer = new datacontractjsonserializer(typeof(rootobject));         rootobject library = (rootobject)serializer.readobject(stream);         messagebox.show("ok");     } } 

please give me hints. have been stuck here loooong while. thank guys!

the json array of rootobject must change

orootobject = ojs.deserialize<rootobject>(jsontext); 

to

orootobject = ojs.deserialize<rootobject[]>(jsontext); 

after in orootobject[0] have json deserialized


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -