【问题标题】:SimpleGeo - Obtaining the Longitude and Latitude from responseSimpleGeo - 从响应中获取经度和纬度
【发布时间】:2011-07-20 22:23:20
【问题描述】:

我有以下 JSON 格式的响应,但似乎无法弄清楚如何从中获取对数和纬度

我试过了

Dim result = JsonConvert.DeserializeObject(Of Dictionary(Of String, Object))(response.Content)

但是当我尝试获取带有“地址”键的项目时......我什么也没得到

这是 JSON 响应

{"query":{"latitude":37.779278,"longitude":-122.416582,"address":"San 弗朗西斯科, CA"},"timestamp":1311197030.697,"features":[{"handle":"SG_4oR6CqYUXZVEotM8ncLk80_37.780722_-122.417364","name":"06075012400","license":"http://creativecommons.org/publicdomain /mark/1.0/","bounds":[-122.421050,37.775147,-122.413365,37.784657],"href":"http://api.simplegeo.com/1.0/features/SG_4oR6CqYUXZVEotM8ncLk80_37.780722_-122.417364.json" ,"abbr":null,"classifiers":[{"category":"US 人口普查","type":"Region","subcategory":"Tract"}]},{"handle":"SG_6qya2EVo227KTsivPoqx28_37.782005_-122.420177","name":"Civic 中心","许可证":"不适合 再分配","bounds":[-122.425482,37.773229,-122.409979,37.790629],"href":"http://api.simplegeo.com/1.0/features/SG_6qya2EVo227KTsivPoqx28_37.782005_-122.420177.json","abbr" :null,"classifiers":[{"category":"Neighborhood","type":"Region","subcategory":null}]},{"handle":"SG_2TnIHbITsDUjuLyhbVeYgx_37.779398_-122.419353","name" :"94102","license":"http://creativecommons.org/publicdomain/mark/1.0/","bounds":[-122.429920,37.769441,-122.404583,37.789226],"href":"http:// /api.simplegeo.com/1.0/features/SG_2TnIHbITsDUjuLyhbVeYgx_37.779398_-122.419353.json","abbr":null,"classifiers":[{"category":"邮政 代码","type":"Region","subcategory":null}]},{"handle":"SG_4gzxFRgOF9YjFAtAiQFpDC_37.793367_-122.397153","name":"程序集 区 13","license":"http://creativecommons.org/publicdomain/mark/1.0/","bounds":[-122.546386,37.708230,-122.281780,37.929824],"href":"http://api .simplegeo.com/1.0/features/SG_4gzxFRgOF9YjFAtAiQFpDC_37.793367_-122.397153.json","abbr":null,"classifiers":[{"category":"立法 District","type":"Region","subcategory":"省级 (下)"}]},{"handle":"SG_2WBEyBsRAqLAHw1QuqXTv1_37.787198_-122.429550","name":"国会 区 8","license":"http://creativecommons.org/publicdomain/mark/1.0/","bounds":[-122.612285,37.708131,-122.281780,37.929824],"href":"http://api .simplegeo.com/1.0/features/SG_2WBEyBsRAqLAHw1QuqXTv1_37.787198_-122.429550.json","abbr":null,"classifiers":[{"category":"立法 区”,“类型”:“地区”,“子类别”:“国家”}]},{“句柄”:“SG_7TAYWdlPlAIzUDT7MVwxmZ_37.759717_-122.693971”,“名称”:“San 弗朗西斯科","license":"http://creativecommons.org/publicdomain/mark/1.0/","bounds":[-123.173825,37.639830,-122.281780,37.929824],"href":"http://api .simplegeo.com/1.0/features/SG_7TAYWdlPlAIzUDT7MVwxmZ_37.759717_-122.693971.json","abbr":null,"classifiers":[{"category":"Administrative","type":"Region","subcategory": "县"}]},{"句柄":"SG_1mNfKHr5aXH7LWgmZL8Uq7_37.759717_-122.693971","名称":"圣 弗朗西斯科","license":"http://creativecommons.org/publicdomain/mark/1.0/","bounds":[-123.173825,37.639830,-122.281780,37.929824],"href":"http://api .simplegeo.com/1.0/features/SG_1mNfKHr5aXH7LWgmZL8Uq7_37.759717_-122.693971.json","abbr":null,"classifiers":[{"category":"Municipal","type":"Region","subcategory": "城市"}]},{"句柄":"SG_4wyrIh6TQId1MiL2cfYa5d_37.759717_-122.693971","name":"San 弗朗西斯科联合学校 区","license":"http://creativecommons.org/publicdomain/mark/1.0/","bounds":[-123.173825,37.639830,-122.281780,37.929824],"href":"http://api .simplegeo.com/1.0/features/SG_4wyrIh6TQId1MiL2cfYa5d_37.759717_-122.693971.json","abbr":null,"classifiers":[{"category":"School District","type":"Region","subcategory":"Unified"}]},{"handle":"SG_4n4ze6xOdAFr0gp1WboZrN_37.551206_-122.127401","name":"San 弗朗西斯科","license":"http://creativecommons.org/publicdomain/mark/1.0/","bounds":[-122.516667,37.191667,-121.733333,38.041667],"href":"http://api .simplegeo.com/1.0/features/SG_4n4ze6xOdAFr0gp1WboZrN_37.551206_-122.127401.json","abbr":null,"classifiers":[{"category":"Urban 区域","type":"Region","subcategory":null}]},{"handle":"SG_1wm1YKOa9HLv5VI8IbHVW7_38.107525_-122.693633","name":"状态 参议院区 3","license":"http://creativecommons.org/publicdomain/mark/1.0/","bounds":[-123.134523,37.708230,-122.281780,38.532067],"href":"http://api .simplegeo.com/1.0/features/SG_1wm1YKOa9HLv5VI8IbHVW7_38.107525_-122.693633.json","abbr":null,"classifiers":[{"category":"立法 District","type":"Region","subcategory":"省级 (上)"}]},{"handle":"SG_2MySaPILVQG3MoXrsVehyR_37.215297_-119.663837","name":"California","license":"http://creativecommons.org/publicdomain/mark/1.0/", "边界":[-124.482003,32.528832,-114.131211,42.009517],"href":"http://api.simplegeo.com/1.0/features/SG_2MySaPILVQG3MoXrsVehyR_37.215297_-119.663837.json","abbr":"CA ","classifiers":[{"category":"Subnational","type":"Region","subcategory":"State"}]},{"handle":"SG_3tLT0I5cOUWIpoVOBeScOx_41.316130_-119.116571","name ":"America/Los_Angeles","license":"creativecommons.org/publicdomain/zero/1.0/","bounds":[-124.733253,32.534622,-114.039345,49.002892],"href":"http:// api.simplegeo.com/1.0/features/SG_3tLT0I5cOUWIpoVOBeScOx_41.316130_-119.116571.json","abbr":null,"classifiers":[{"category":"时间 Zone","type":"Region","subcategory":null}]},{"handle":"SG_3uwSAEdXVBzK1ZER9Nqkdp_45.687160_-112.493107","name":"United 的国家 美国","license":"http://creativecommons.org/publicdomain/mark/1.0/","bounds":[-179.142471,18.930138,179.781150,71.412180],"href":"http://api. simplegeo.com/1.0/features/SG_3uwSAEdXVBzK1ZER9Nqkdp_45.687160_-112.493107.json","abbr":null,"classifiers":[{"category":"National","type":"Region","subcategory":null }]}],"天气":{"wind_speed":"6.9 每米 秒","温度":"78F","露点":"59F","cloud_cover":"0%","wind_direction":"325 度数","预测":{"今晚":{"条件":"大部分 多云","降水":"0%","温度":{"max":"58F","min":"55F"}},"明天":{"条件":"晴","降水":"0%","温度":{"max":"70F","min":"56F"}},"今天":{"条件":"晴","降水":"0% ","温度":{"max":"73F","min":"59F"}}},"conditions":"Clear"},"demographics":{"population_density":7489},"intersections" :[{"距离":38.43225250350512,"几何":{"类型":"点","坐标":[-122.4167858,37.779583799999997]},"属性":{"高速公路":[{"osm_way_id":" 33789567","类型":"住宅","名称":"富尔顿 街道"},{"osm_way_id":"26988030","type":"tertiary","name":"Larkin Street"}],"attribution":"(c) OpenStreetMap (http://openstreetmap.org/) 和 贡献者","license":"http://creativecommons.org/licenses/by-sa/2.0/"},"type":"Feature","id":"65287204"},{"distance":69.25254468826954 ,"几何":{"type":"Point","coordinates":[-122.4165794,37.778655200000003]},"properties":{"highways":[{"osm_way_id":"26988030","type":"三级","名称":"拉金 街道"},{"osm_way_id":"8920461","type":"unclassified","name":"Grove Street"}],"attribution":"(c) OpenStreetMap (http://openstreetmap.org/) 和 贡献者","license":"http://creativecommons.org/licenses/by-sa/2.0/"},"type":"Feature","id":"65354417"},{"distance":139.2095933887024 ,"几何":{"type":"Point","coordinates":[-122.41696140000001,37.780493499999999]},"properties":{"highways":[{"osm_way_id":"27167270","type":"住宅","名称":"麦卡利斯特 街道"},{"osm_way_id":"26988030","type":"tertiary","name":"Larkin Street"}],"attribution":"(c) OpenStreetMap (http://openstreetmap.org/) 和 贡献者","license":"http://creativecommons.org/licenses/by-sa/2.0/"},"type":"Feature","id":"65352337"},{"distance":139.9292506517826 ,"几何":{"type":"Point","coordinates":[-122.415127,37.779789000000001]},"properties":{"highways":[{"osm_way_id":"8915763","type":"住宅","名称":"富尔顿 街道"},{"osm_way_id":"26988009","type":"tertiary","name":"Hyde Street"}],"attribution":"(c) OpenStreetMap (http://openstreetmap.org/) 和 贡献者","license":"http://creativecommons.org/licenses/by-sa/2.0/"},"type":"Feature","id":"65287201"},{"distance":152.92687955288244 ,"几何":{"type":"Point","coordinates":[-122.4149213,37.778867400000003]},"properties":{"highways":[{"osm_way_id":"26988009","type":"三级","名称":"海德 街道"},{"osm_way_id":"8920461","type":"unclassified","name":"Grove Street"}],"attribution":"(c) OpenStreetMap (http://openstreetmap.org/) 和 贡献者","license":"http://creativecommons.org/licenses/by-sa/2.0/"},"type":"Feature","id":"65360267"}],"address":{ “几何”:{“坐标”:[-122.41670097091016,37.77925384607872],“类型”:“点”},“属性”:{“地址”:“164 Larkin St","distance":"0.01","postcode":"94109","city":"San 弗朗西斯科","县":"圣 弗朗西斯科","province":"CA","country":"US"},"type":"Feature"}}

【问题讨论】:

    标签: .net json.net simplegeo


    【解决方案1】:

    在这个例子中,我希望有一个名为“query”的键返回另一个字典。那会有经度和纬度的键。

    Dim queryDict = result.Item("query")
    Dim lng = queryDict.Item("longitude")
    Dim lat = queryDict.Item("latitude")
    

    请原谅语法,但我已经很久没有做过 .net/VB 了,所以不知道这是否正确。

    如果将您拥有的 JSON 可视化,它也可能对您有所帮助。尝试将其粘贴到此工具中并单击渲染按钮: http://chris.photobooks.com/json/default.htm

    【讨论】:

      猜你喜欢
      • 2020-11-07
      • 1970-01-01
      • 1970-01-01
      • 2019-03-25
      • 2016-09-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多