【发布时间】:2019-11-01 21:49:03
【问题描述】:
我正在尝试调试我的 JProperty 对象,但不知何故我无法从该对象中获取所有数据。当我调试 te JProperty 时,它说它有我试图接收的数据,但我只能获得其中的一部分,解释:
所以我的响应 JSON 看起来像这样:
{"url":"www.microsoft0nline.nl\/test.php","time":"2019-06-19 09:50:49","stringvalue":"otherValue1","intvalue":433,"array":["35","37","43"],"otherObject1":{"name":"object1","description":"A object type","size":120}}
我正在使用以下代码进行迭代:
foreach (JProperty property in jsonResponse.Properties())
{
}
所以当我在调试模式下运行我的代码并调试这些属性时,我得到以下信息:
正如大家所见,property 的父级包含对象“otherObject1”。
现在我用下面的代码遍历这个属性:
foreach (var itemsOfResponse in property)
{
var dataJson = itemsOfResponse;
System.Diagnostics.Debug.WriteLine(dataJson);
}
我的调试器中的响应如下所示:
www.microsoft0nline.nl/test.php
2019-06-19 10:01:49
otherValue1
433
[
"35",
"37",
"43"
]
响应包含除“otherObject1”之一之外的我的 json 响应的所有值,这怎么可能?有没有办法获取这些属性的键值(url、stringvalue、intvalue 等)?
希望有人能帮帮我!
【问题讨论】: