json串:{"UserName":"","Birthday":"","Sex":"","Nationality":"","Educational":[{"date":"","school":"","speciality":"","degree":"","witness":"","contact":""},{"date":"","school":"","speciality":"","degree":"","witness":"","contact":""},{"date":"","school":"","speciality":"","degree":"","witness":"","contact":""}]} Person person = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize<Person>(jsonStr);
UserName,Birthday等都有值,但Educational却是空的。Educational应当如果解析?望大家不吝赐教
不知道你的实体类是怎么设置的,你可以定义一个对像,然后转换成JSON,看看跟你现在的json字符串有什么区别
两者相同的,且json串验证正确。现在不明白如何解析上面那段从客户端传过来的json串
@卤水兄: 你把你定义的实体类给我,我来试试
@chenping2008: Educational 这个应该是个list<这里也是一个实体来>
复制你的代码可以生成,Educational也有值。看你实体Educational是什么?我定义成数组、IList、List都没问题。
Person类中属性Educational是定义为List<T>的,原因是我把类中属性Educational写成Educational_list,以为这样好区分。原来还是得与json串对应来写Person类的属性。非常感谢@chenping2008,@向往-SONG
我也碰到相同的问题,请问如何解决
刚刚试了下 定义成list就真没问题了。
是基于winform 的呢?解决掉了没有?
我也碰到相同的问题 怎么解决