首页 > 解决方案 > 从字符串层次对象访问对象

问题描述

我有一个这样的字符串对象。我曾尝试使用 newtonsoft json 转换器进行反序列化,但它会导致 null 对象。我知道背后的原因是我试图转换为的对象在“数据”中。因此,它在转换后总是为每个属性返回 Null。

我想知道如何直接从这个对象访问“数据”?

{"data":{"providerRef":null,"orderId":"4579144","orderStatus":"x:app_pending","applicantInterfaceURL":"http://google.com","successful":true,"error":null,"reportAddress":null,"correlationId":"55f7022c-28f9-490a-8dd1-b30a40e3467a"},"status":0,"error":{"actionArguments":null,"errorCode":null,"errors":null,"message":null}}

现在,我已经实现了它在此处输入图像描述

VolunteerBackgroundCheckResponse类具有以下属性: 在此处输入图像描述

任何人都可以帮助我仅从 json 字符串中获取数据对象吗?

标签: serializationjson-deserialization

解决方案


这解决了。我为此目的使用了 JObject,并收到了主对象下的所有属性。我访问了“数据”并将其反序列化。


推荐阅读