Esempio n. 1
0
        public void DeserialzeGeoCoderResponse()
        {
            var json     = @"{""status"":""1"",""info"":""OK"",""infocode"":""10000"",""count"":""1"",""geocodes"":[{""formatted_address"":""北京市朝阳区方恒国际中心|A座"",""country"":""中国"",""province"":""北京市"",""citycode"":""010"",""city"":""北京市"",""district"":""朝阳区"",""township"":[],""neighborhood"":{""name"":[],""type"":[]},""building"":{""name"":[],""type"":[]},""adcode"":""110105"",""street"":[],""number"":[],""location"":""116.480656,39.989677"",""level"":""门牌号""}]}";
            var firstGeo = client.DeserialzeObject <GeoCoderResponse>(json).geocodes.First();

            Assert.IsTrue(firstGeo.city == "北京市");
            Assert.IsTrue(firstGeo.formatted_address == "北京市朝阳区方恒国际中心|A座");
            Assert.IsTrue(firstGeo.province == "北京市");
            Assert.IsTrue(firstGeo.citycode == "010");
            Assert.IsTrue(firstGeo.district == "朝阳区");
        }