反序列化,JSON,WP7

时间:2012-03-16 07:21:58

标签: json windows-phone-7 serialization

我试图反序化这个Json:

[
    {
        "Address": "String content",
        "CategoryId": 2147483647,
        "CategoryName": "String content",
        "City": "String content",
        "Email": "String content",
        "GroupComment": "String content",
        "GroupName": "String content",
        "IntegrationType": "String content",
        "Location": {
            "Latitude": 1267432330000000,
            "Longitude": 1267432330000000
        },
        "Phone": "String content",
        "StoreComment": "String content",
        "StoreName": "String content",
        "Website": "String content",
        "ZipCode": "String content"
    }
]
  .......

我有2个班级:

    public class Stores
    {
        public string Address { get; set; }
        .......
        public GeoLocation geoLocation { get; set; }
    }

    public class GeoLocation
    {
        public double Latitude { get; set; }
        public double Longitude { get; set; }
    }

我正在对Json进行反序列化:

Stores[] st = new Stores[200];
MemoryStream ms = new MemoryStream(Encoding.Unicode.GetBytes(e.Result));
DataContractJsonSerializer serializer = new DataContractJsonSerializer(st.GetType());
st = serializer.ReadObject(ms) as Stores[];
ms.Close();

我得到地址等,但是GeoLocation“无法评估表达式”。

有什么问题?

彼得

1 个答案:

答案 0 :(得分:1)

尝试将geoLocation成员名称更改为Location?