【发布时间】:2016-12-20 09:50:45
【问题描述】:
我正在尝试使用 Json.NET 库读取包含 JsonArray 中的一些值的 json 对象。我想将每个数组值放入变量中。以下是 Json 字符串。请指导,谢谢。
{"enad_list":
[{
"et_cnic":"1090202369011",
"et_name":"Its me",
"et_father_husband_name":"My father name",
"et_present_add":"Its my address",
"et_permanent_add":"Its my another address ",
"et_date_of_birth":"10-9-1982",
"et_birth_place":"My Birth place",
"et_expiry_date":"2020-12-15"
}]
}
编辑: 到目前为止,我已经尝试了此代码并收到错误。错误请看图片
string jsonData =@"{""enad_list"":[{""et_cnic"":""1090202369011"",""et_name"":""Its me""}]}";
dynamic jsonData = JObject.Parse(abc.ToString());
int cnic = jsonData.enad_list.et_cnic;
【问题讨论】:
-
newtonsoft.com/json 有简单的例子
-
问题是什么?您是否在问使用哪种方法来反序列化此字符串?您是否检查过文档或只是在谷歌上搜索过这个?你尝试过失败的事情吗?
-
我猜这个答案是你需要的:stackoverflow.com/questions/4749639/…
-
@Panagiotis,是的,无论我们使用哪种方法,我都需要将每个数组值转换为变量,谢谢。