0

json数据是这样的

{"content": 
[{"url": "http://job.hust.edu.cn/show/recruitcouncil/recruitfair.htm?id=20830",
 "company": {"id": "50e25f89b041be4510f09cf8", "index": ["\u67d0", "\u91cd\u5e86\u5e02", "\u91cd\u5e86", "\u653f\u6cd5", "\u673a\u5173"], "name": "\u91cd\u5e86\u5e02\u67d0\u653f\u6cd5\u673a\u5173", "alias": []}, "starttime": 1357606832.0, "address": {"university": "\u534e\u4e2d\u79d1\u6280\u5927\u5b66", "city": "\u6b66\u6c49", "accurate": {"name": "\u5927\u5b66\u751f\u6d3b\u52a8\u4e2d\u5fc3", "longitude": 114.4141960144043, "latitude": 30.51835035703118, "id": "4f4858f1cea1755b6c000000"}, "detail": "\u5927\u5b66\u751f\u6d3b\u52a8\u4e2d\u5fc3302\u5ba4"}, "endtime": 1357615800.0, "id": "50e25f89b041be4510f09cfa"}, {"url": "http://job.hust.edu.cn/show/recruitcouncil/recruitfair.htm?id=20914", "company": {"id": "50ea9ef2b041be0b2669b246", "index": ["\u5e7f\u897f", "\u8d28\u76d1\u5c40", "\u8d28\u76d1"], "name": "\u5e7f\u897f\u8d28\u76d1\u5c40", "alias": []}, "starttime": 1357608654.0, "address": {"city": "\u6b66\u6c49", "university": "\u534e\u4e2d\u79d1\u6280\u5927\u5b66", "detail": "\u4e3b\u6821\u533a\u6559\u5de5\u6d3b\u52a8\u4e2d\u5fc3"}, "endtime": 1357615800.0, "id": "50ea9ef2b041be0b2669b248"}, {"url": "htt://job.hust.edu.cn/show/recruitcouncil/recruitfair.htm?id=20907", "company": {"id": "50ea9ef2b041be0b2669b243", "index": ["\u53d1\u5c55", "\u7535\u529b", "\u6c47", "\u96c6\u56e2", "\u4e30", "\u6c47\u8fbe\u4e30", "\u73e0\u6d77", "\u8fbe"], "name": "\u73e0\u6d77\u6c47\u8fbe\u4e30\u7535\u529b\u53d1\u5c55\uff08\u96c6\u56e2", "alias": []}, "starttime": 1357803004.0, "address": {"city": "\u6b66\u6c49", "university": "\u534e\u4e2d\u79d1\u6280\u5927\u5b66", "detail": "\u897f\u4e5d\u697c224\u5ba4"}, "endtime": 1357813800.0, "id": "50ea9ef2b041be0b2669b245"}, {"url": "htt://job.hust.edu.cn/show/recruitcouncil/recruitfair.htm?id=20717", "company": {"id": "50d07331b041be3b0b10f707", "index": ["\u89c1\u9762", "\u6bd5\u4e1a\u751f", "\u6bd5\u4e1a", "\u4f9b\u9700", "\u5c4a", "\u4f9b\u9700\u89c1\u9762", "\u4e1a\u751f", "\u9762\u4f1a", "\u89c1\u9762\u4f1a", "\u4f1a", "2013"], "name": "2013\u5c4a\u6bd5\u4e1a\u751f\u4f9b\u9700\u89c1\u9762\u4f1a", "alias": []}, "starttime": 1363654837.0, "address": {"university": "\u534e\u4e2d\u79d1\u6280\u5927\u5b66", "city": "\u6b66\u6c49", "accurate": {"name": "\u5149\u8c37\u4f53\u80b2\u9986", "longitude": 114.41835880279541, "latitude": 30.508552777754073, "id": "4f485921cea1755b6d00000f"}, "detail": "\u5149\u8c37\u4f53\u80b2\u9986"}, "endtime": 1363680000.0, "id": "50e25f89b041be4510f09cf7"}], "deleted": [], "count_query": 4}

我的代码是

[DataContract]
public class Job
{
    [DataMember(Name = "url")]
    public string Url { set; get; }
    [DataMember(Name = "company")]
    public Company Company { set; get; }


    [DataMember(Name = "starttime")]
    public long StartTime { set; get; }
    [DataMember(Name = "address")]
    public Address Address { set; get; }
    [DataMember(Name="endtime")]
    public long EndTime { set; get; }
    [DataMember(Name="id")]
    public string Id { set; get; }

}

[DataContract]
public class Address
{
    [DataMember(Name = "university")]
    public String University { set; get; }
    [DataMember(Name = "city")]
    public String City { set; get; }
    [DataMember(Name="accurate")]
    public Accurate Accurate { set; get; }

    [DataMember(Name="detail")]
     public String Detail { set; get; }      
}

[DataContract]
public class Accurate
{
    [DataMember(Name = "name")]
    public string Name { set; get; }
    [DataMember(Name = "longitude")]
    public double Longitude { set; get; }
    [DataMember(Name="latitude")]
    public double Latitude { set; get; }

    [DataMember(Name = "id")]
    public string Id { set; get; }
    [DataMember(Name = "detail")]
    public string Detail { set; get; }

}
[DataContract]
public class Company
{
    [DataMember(Name = "id")]
    public String Id { set; get; }
    [DataMember(Name = "index")]
    public string[] Index { set; get; }
    [DataMember(Name = "name")]
    public String Name { set; get; }
    [DataMember(Name="alias")]
    public string[] alias { set; get; }



}


 public static T JsonToObject<T>(string json)
    {
       //json = str;
        if (!string.IsNullOrEmpty(json))
        {
            var ms = new MemoryStream(Encoding.UTF8.GetBytes(json));
            var ser = new DataContractJsonSerializer(typeof(T));
            return (T)ser.ReadObject(ms);
        }
        return default(T);
    }




     when I debug I get the result 
jsonDeserializer    = null  
KnownDataContracts = Could not evaluate expression
knownDataContracts  null    

我无法从此代码中获得任何结果,有人可以帮我解析这个 json,非常感谢!

4

1 回答 1

1

似乎 JSON 响应的某些值已被 unicode 转义。看看这篇文章。我相信它会回答你的问题。

于 2013-02-03T04:38:38.300 回答