我正在开发一个移动空中应用程序。对于通信,我正在使用 wcf 服务。现在我的问题是这个,我正在尝试使用 json.net 反序列化一个数组数组。子数组是类型化的。所以,我在移动端的课程如下:
package Model.VO.PHCDATA
{
[Bindable]
[RemoteClass(alias="Model.PCHModel.VODadosPHC")]
public class VoBi
{
private var _BIstamp:String;
private var _ivaincl:Number;
private var _vendnm:String;
private var _vendedor:Number;
private var _iva:Number;
private var _lordem:Number;
private var _tabiva:Number;
private var _txiva:Number;
private var _familia:String;
....
}
}
另一个是:
package Model.VO.PHCDATA
{
[Bindable]
[RemoteClass(alias="Model.PCHModel.VODadosPHC")]
public class VOBO
{
private var _BOstamp:String;
private var _vendedor:Number;
private var _vendnm:String;
....
}
}
对应的c#类如下:
[DataContract(Name = "VoBi")]
public class VoBi
{
[DataMember(IsRequired = true, Name = "BIstamp", Order = 0)]
public string BIstamp { get; set; }
[DataMember(IsRequired = true, Name = "ivaincl", Order = 1)]
public decimal ivaincl { get; set; }
[DataMember(IsRequired = true, Name = "vendnm", Order = 2)]
public string vendnm { get; set; }
[DataMember(IsRequired = true, Name = "vendedor", Order = 3)]
public decimal vendedor { get; set; }
....
}
另一个:
[DataContract(Name = "VOBO")]
public class VOBO
{
[DataMember(IsRequired = true, Name = "BOstamp", Order = 0)]
public string BOstamp { get; set; }
[DataMember(IsRequired = true, Name = "vendedor", Order = 1)]
public decimal vendedor { get; set; }
[DataMember(IsRequired = true, Name = "vendnm", Order = 2)]
public string vendnm { get; set; }
[DataMember(IsRequired = true, Name = "nmdos", Order = 3)]
public string nmdos { get; set; }
[DataMember(IsRequired = true, Name = "ndos", Order = 4)]
public decimal ndos { get; set; }
.....
}
要发送到服务器的相应json字符串是这个:
{
"DADOSBI": [
{
"edebito": 0,
"desconto": 92.121,
"vendedor": 0,
"desc2": 222.343,
"iva": 23,
"ettdeb": 123.555,
"lordem": 12,
"tabiva": 2.1,
....
},
{
"edebito": 0,
"desconto": 92.121,
"vendedor": 1,
"desc2": 222.343,
"iva": 23,
"ettdeb": 123.555,
"lordem": 12,
"tabiva": 2.1,
....
}
],
"DADOSBO": [
{
"estab": 123.88,
"etotaldeb": 123,
"obs": "",
"vendedor": 0,
"statuspda": "qqqqqqqqqqqq",
"ebo_2tvall": 12,
"ebo_2tdes1": 12.11,
...
},
{
"estab": 123.88,
"etotaldeb": 123,
"obs": "",
"vendedor": 1,
"statuspda": "qqqqqqqqqqqq",
"ebo_2tvall": 12,
....
}
]
}
我该如何处理?我是否使用 json.net CustomCreationConverter 反序列化数据?并获得用我提到的类填充的相应数组,还是我使用另一种方法?帮助将不胜感激。提前致谢。