对于某些端点 SimpleGeo.com 返回如下内容:
{
"geometry":{
"type":"Point",
"coordinates":[
-122.421583,
37.795027
]
},
"type":"Feature",
"id":SG_5JkVsYK82eLj26eomFrI7S_37.795027_-122.421583@1291796505,
"properties":{
"province":"CA",
"city":"San Francisco",
"name":"Bell Tower",
"tags":[],
"country":"US",
"phone":"+1 415 567 9596",
"href": http://api.simplegeo.com/1.0/features/SG_5JkVsYK82eLj26eomFrI7S_37.795027_-122.421583@1291796505.json,
"address":"1900 Polk St",
"owner":"simplegeo",
"postcode":"94109",
"classifiers":[
{
"category":"Restaurant",
"type":"Food & Drink",
"subcategory":""
}
]
}
}
(参见http://simplegeo.com/docs/api-endpoints/simplegeo-features#get-detailed-information)。
现在我在反序列化“属性”部分时遇到了一个小问题。如果我使用例如一种 Dictionary 类型,它会将其转换为一个不错的字典,但 'classifiers' 值只是一个 {} 字符串。
有没有办法告诉 json.net 将子数组反序列化为另一个 Dictionary 等?基本上,该返回中有一定数量的普通键/值,但我知道可能不仅仅是“分类器”子数组(参见“标签”),而且值的深度可能更进一步。 ..
所以基本上我想知道的是,我如何正确反序列化属性部分?有什么建议么?我不介意编写自己的 JsonConverter,但也许已经有一种方法可以不用它。