我在Windows Phone 7.1(芒果)上使用了很棒的NewtonSoft.Json库。
我想访问Bing json答案的深层属性(红色箭头):
我在resultado
变量上分配了已回答的字符串,我试图这样做:
JObject o = JObject.Parse(resultado);
JsonAddress unaAddress =
JsonConvert
.DeserializeObject<JsonAddress>(o["resourceSets"][0]["resources"][0].ToString());
MessageBox.Show(unaAddress.Coordinates.X); // iexample..
但我不知道如何定义类JsonAddress
以获取我需要的信息。
public class JsonAddress
{
// public xxxx Coordinates { get; set; }
}
任何帮助?
感谢。
答案 0 :(得分:0)
我找到了它:
以这种方式定义类(和子类):
public class JsonAddress
{
public string Name { get; set; }
public JsonPoint Point { get; set; }
}
public class JsonPoint
{
public double[] Coordinates { get; set; }
}
以这种方式访问它:
MessageBox.Show(unaAddress.Point.Coordinates[0] + ", " +
unaAddress.Point.Coordinates[1]);
感谢您的浪费时间......: - \