2014-05-11 22 views
0

你好我提出請求/ respomse然後我用StreamReader讀取我得到的字符串的數據,這個數據是Json類型,我需要使我的字符串(與Json數據)可讀取將其轉換爲對象,我可以使用我需要的所有數據如何將Json轉換爲C#類的定義,並反序列化它

{"success":true,"errorInfo":{"errorCode":null,"errorTitle":null,"errorDescription":null,"errorKeyTitle":null,"errorKeyDescription":null,"debugMessage":null,"debugTrace":null},"data":{"cuenta":null,"periodo":null,"importe":null,"conceptos":null,"divisa":null,"descCtaIban":"01824649840201502683","descEmpresa":"VISONIC IBERICA DE SEGURIDAD S.L.","descOficina":"TB BARCELONA","descBanco":"BANCO BILBAO VIZCAYA ARGENTARIA S.A.","paginacionTLSMT016":"","paginacionTLSMT017":"M201311050001+0000000000000591800","codError":0,"codRetorno":0,"descripcion":"OK","movimientos":[{"descConceptoTx":"RECIBO DE ALQUILER","descConcepto":"RECIBO DE ALQUILER    ","codOficinaOrigen":"4649","numeroTalon":"000000000","indicadorDH":"D","divisaOrigen":null,"codigoMes":"QJ","fechaDocumento":"20140502","identificadorDocumento":"000000954639718","bancoProducto":"0182","oficinaProducto":"4649","contrapartidaProducto":"0020","folioProducto":"00000000150268","fechaContable":"02/05/2014","fechaValor":"02/05/2014","importe":"-1.184,99","saldo":"0,00","codigo":"0734","concepto":"N 2014122001830697 ARVAL SERV","oficina":"TB BARCELONA","divisa":"EUR","pais":"ES","cuenta":"01824649840201502683","banco":"BANCO BILBAO VIZCAYA ARGENTARIA S.A.","infAdicional":"4649","importeTotal":true,"saldoContable":"","saldoValor":""},{"descConceptoTx":"TRASPASO DE APUNTES AGRUPADOS","descConcepto":"TRASPASO DE APUNTES AGRUPADOS ","codOficinaOrigen":"4649","numeroTalon":"000000000","indicadorDH":"H","divisaOrigen":null,"codigoMes":"","fechaDocumento":"00010101","identificadorDocumento":"000000000000000","bancoProducto":"0000","oficinaProducto":"0000","contrapartidaProducto":"0000","folioProducto":"00000000000000","fechaContable":"02/05/2014","fechaValor":"02/05/2014","importe":"1.184,99","saldo":"1.184,99","codigo":"0422","concepto":"TRASP. DST: 4649-010-0150040","oficina":"TB BARCELONA","divisa":"EUR","pais":"ES","cuenta":"01824649840201502683","banco":"BANCO BILBAO VIZCAYA ARGENTARIA S.A.","infAdicional":"4649","importeTotal":true,"saldoContable":"","saldoValor":""}, 
+0

另外,如果你不知道大小或您的對象類型,您可能想要使用動態變量類型。 – Falgantil

回答

2

您發佈的JSON無效。它可能被截斷。

使用下面的鏈接自動生成一個對象http://json2csharp.com/

假設你的根類的名字是RootObject

然後調用下面的代碼

var result = JsonConvert.DeserializeObject<RootObject>(json); 
+0

這是我的錯誤,我沒有粘貼所有的Json,因爲它是很長的,但你給這個網站解決所有問題thanx – user3567884

相關問題