日期:2014-05-20  浏览次数:20861 次

asp.net 后台解析json字符串 用JavaScriptSerializer类 可解析出来的数据是空
JavaScriptSerializer json = new JavaScriptSerializer();
 string fd = "{\"qweq\":[{\"SupercargoBatchId\":\"1\"}]}";
 SupercargoBatchjson supercargoBatchjson = json.Deserialize<SupercargoBatchjson>(fd);
supercargoBatchjson  它为空对象
------解决方案--------------------
你的json对应的类结构应该是A这样的

全部后台代码
public class A
    {
        public IEnumerable<SupercargoBatchjson> qweq { get; set;}
    }

public class SupercargoBatchjson 
{
    private string _supercargoBatchId;

    public string SupercargoBatchId
    {
        get { return _supercargoBatchId; }
        set { _supercargoBatchId = value; }
    }
   



A a = json.Deserialize<A>(fd);
SupercargoBatchjson supercargoBatchjson =a.qweq.First();