wpf - Iterating though desearialised JSON via HttpWebResponse -


in wpf application returning json this

{ "accounthistory":[ { "accountnumber":123456, "dailyendingbalances": [ {"balancedate":"\/date(14508540000000000)\/","endingbalance":2511.5700}, //other elements ], "transactions":[ { "transactionid":"98787676", //other elements },  { "transactionid":"2683901",  //other elements  }],  "issuccessful":true,  "statuscode":0, "statusmessage":"success" ], "issuccessful":true, "statuscode":0, "statusmessage":"success } 

and being deserialised this

using response httpwebresponse = directcast(request.getresponse(), httpwebresponse)             dim deserializer new datacontractjsonserializer(gettype(abank.ahistoryresponse))             responseobject = directcast(deserializer.readobject(response.getresponsestream()), abank.ahistoryresponse)         end using 

the following classes pick up, , work correctly, root elements

public property issuccessful() boolean                     return m_issuccessful         end         set             m_issuccessful = value         end set     end property     private m_issuccessful boolean      public property statuscode() integer                     return m_statuscode         end         set             m_statuscode = value         end set     end property     private m_statuscode integer      public property statusmessage() string                     return m_statusmessage         end         set             m_statusmessage = value         end set     end property     private m_statusmessage string 

and returned this....

 dim issuccessful boolean = responseobject.issuccessful         dim vstatuscode integer = responseobject.statuscode         dim vmessage string = responseobject.statusmessage 

i have tried number of ways return sub elements, adding above class

 public sub new()         m_accountnumber = new list(of accounthistoryaccountnumber)         m_transactions = new list(of accounthistorytransactions)     end sub     public property accountnumber list(of accounthistoryaccountnumber)                     return m_accountnumber         end         set(value list(of accounthistoryaccountnumber))             m_accountnumber = value         end set     end property     private m_accountnumber list(of accounthistoryaccountnumber) 

...and this

public class accounthistoryaccountnumber      public property accountnumber() long                     return m_accountnumber         end         set             m_accountnumber = value         end set     end property     private m_accountnumber long      public property statusmessage() string                     return m_statusmessage         end         set             m_statusmessage = value         end set     end property     private m_statusmessage string      public property issuccessful() boolean                     return m_issuccessful         end         set             m_issuccessful = value         end set     end property     private m_issuccessful boolean      public property statuscode() integer                     return m_statuscode         end         set             m_statuscode = value         end set     end property     private m_statuscode integer   end class 

but returns zero

dim vaccounts integer = responseobject.accountnumber.count 

i think main problem accountnumber contains both data , array , somehow neurons not firing configuration :-)

any pointers appreciated...

thank you

in end found useful utility here http://json2csharp.com/ converts json c# classes...

i caught incoming raw json using fiddler, pasted utility , able correct class structures this

 public class rootobject      public property accounthistory() list(of accounthistory)                     return m_accounthistory         end         set(value list(of accounthistory))             m_accounthistory = value         end set     end property     private m_accounthistory list(of accounthistory)      public sub new()         m_accounthistory = new list(of accounthistory)     end sub     public property issuccessful() boolean                     return m_issuccessful         end         set             m_issuccessful = value         end set     end property     private m_issuccessful boolean      public property statuscode() integer                     return m_statuscode         end         set             m_statuscode = value         end set     end property     private m_statuscode integer      public property statusmessage() string                     return m_statusmessage         end         set             m_statusmessage = value         end set     end property     private m_statusmessage string end class   public class accounthistory      public property accountnumber() long                     return m_accountnumber         end         set(value long)             m_accountnumber = value         end set     end property     private m_accountnumber long      public sub new()         m_transactions = new list(of transactions)     end sub      public property transactions() list(of transactions)                     return m_transactions         end         set(value list(of transactions))             m_transactions = value         end set     end property      private m_transactions list(of transactions)      public property issuccessful() boolean                     return m_issuccessful         end         set             m_issuccessful = value         end set     end property     private m_issuccessful boolean      public property statuscode() integer                     return m_statuscode         end         set             m_statuscode = value         end set     end property     private m_statuscode integer      public property statusmessage() string                     return m_statusmessage         end         set             m_statusmessage = value         end set     end property     private m_statusmessage string  end class  public class transactions      public property transactionid() string                     return m_transactionid         end         set(value string)             m_transactionid = value         end set     end property     private m_transactionid string      public property posteddate() string                     return m_posteddate         end         set(value string)             m_posteddate = value         end set     end property     private m_posteddate string      public property checknumber() string                     return m_checknumber         end         set(value string)             m_checknumber = value         end set     end property     private m_checknumber string      public property tracenumber() long                     return m_tracenumber         end         set(value long)             m_tracenumber = value         end set     end property      private m_tracenumber long  end class 

Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -