我有JSON这样的:
编辑:JSON是错误的。发送json对象数组到.net web服务
[WebMethod]
[ScriptMethod(UseHttpGet = false, ResponseFormat = ResponseFormat.Json)]
public string ProcessData(VehiclesData VehiclesData)
{
//...Do stuff here with VehiclesData
}
public class VehiclesData
{
public List<Vehicle> VehiclesList = new List<Vehicle>();
public class Vehicle
{
private string year = string.Empty;
private string make = string.Empty;
private string model = string.Empty;
public string Year { get { return this.year; } set { this.make = value; } }
public string Make { get { return this.make; } set { this.make = value; } }
public string Model { get { return this.model; } set { this.model = value; } }
}
}
我收到“对象不匹配目标类型”:我曾用手
var VehiclesData = {
"VehiclesData": {
"VehiclesList": [
{ "year": "2010", "make": "honda", "model": "civic" },
{ "year": "2011", "make": "toyota", "model": "corolla" },
{ "year": "2012", "make": "audi", "model": "a4" }]
}
}
我想发送给.NET Web服务API这样的类型吧。
有了扁平的JSON对象,我得到的数据很好,但对象和一个C#列表的数组,我有点失落。
你的json无效http://json2csharp.com/ – saj 2014-10-01 01:43:05