我有一个AJAX调用,它将以下JSON发送到我的webservice:
{"Tags":["12","5","2"],"TargetId":"36946","TargetType":"Officer"}
这是webservice和自定义类:
[WebMethod]
public string UpdateTags(string PostParameters)
{
JavaScriptSerializer serializer = new JavaScriptSerializer();
var tagData = serializer.Deserialize<TagData>(PostParameters);
// do some stuff with tagData
}
[Serializable]
[DataContract(Name = "PostParameters")]
public class TagData
{
[DataMember(Name = "TargetId")]
string TargetId { get; set; }
[DataMember(Name = "TargetType")]
string TargetType { get; set; }
[DataMember(Name = "Tags")]
List<int> Tags { get; set; }
}
不幸的是,tagData的属性为null。我做得不好?