asp.net 后台解析json字符串 用JavaScriptSerializer类 可解析出来的数据是空
JavaScriptSerializer json = new JavaScriptSerializer();string fd = "{\"qweq\":[{\"SupercargoBatchId\":\"1\"}]}";
SupercargoBatchjson supercargoBatchjson = json.Deserialize<SupercargoBatchjson>(fd);
supercargoBatchjson 它为空对象 json --------------------编程问答-------------------- 大哥们JSon 我就差这一步了 求各位大哥了 自己先顶一下 --------------------编程问答-------------------- SupercargoBatchjson 与json的结构不同。或者你大小写错了 --------------------编程问答-------------------- public class SupercargoBatchjson
{
private string _supercargoBatchId;
public string SupercargoBatchId
{
get { return _supercargoBatchId; }
set { _supercargoBatchId = value; }
}
} --------------------编程问答-------------------- 江湖救急 给位大侠们 帮忙顶一下。感激不尽 --------------------编程问答-------------------- public class A
{
public IEnumerable<SupercargoBatchjson> qweq { get; set;}
}
var a = json.Deserialize<A>(fd);
*****************************************************************************
http://feiyun0112.cnblogs.com/ --------------------编程问答-------------------- var a = json.Deserialize<A>(fd);
您这个是前台分析把
我需要的是后台分析
JavaScriptSerializer json = new JavaScriptSerializer();
string fd = "{\"qweq\":[{\"SupercargoBatchId\":\"1\"}]}";
SupercargoBatchjson supercargoBatchjson = json.Deserialize<SupercargoBatchjson>(fd);
supercargoBatchjson 它为空对象 --------------------编程问答-------------------- var a = json.Deserialize<A>(fd);
SupercargoBatchjson supercargoBatchjson =a.qweq。First(); --------------------编程问答-------------------- 楼上那位大哥 您看var a = json.Deserialize<A>(fd);
SupercargoBatchjson supercargoBatchjson =a.qweq。First();
var 这词 一看就知道是 JS 代码 我需要的是后台解析json 的二维代码
json格式是 "{\"qweq\":[{\"SupercargoBatchId\":\"1\"}]}";
是一个数组 --------------------编程问答-------------------- var C# 3.0就开始支持le,
A a = json.Deserialize<A>(fd);
SupercargoBatchjson supercargoBatchjson =a.qweq.First(); --------------------编程问答-------------------- JavaScriptSerializer json = new JavaScriptSerializer();
string fd = "{\"qweq\":[{\"SupercargoBatchId\":\"1\"}]}";
SupercargoBatchjson supercargoBatchjson = json.Deserialize<SupercargoBatchjson>(fd);
supercargoBatchjson 它为空对象
大哥您看
List<SupercargoBatchjson> supercargoBatchjson = json.Deserialize<List<SupercargoBatchjson>>(fd); 这个是转换成数组对象的 因为上面转换对象有错 根据JSON格式来看是一个数组格式的 换成转换数组形式 报错
您能否针对性的帮我解决这个问题 啊 或是 贴出您写的后台代码 --------------------编程问答-------------------- 你的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();
补充:.NET技术 , .NET技术前瞻