Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在C中解析嵌套JSON#_C#_Json_Parsing - Fatal编程技术网

C# 在C中解析嵌套JSON#

C# 在C中解析嵌套JSON#,c#,json,parsing,C#,Json,Parsing,大家好,这是消息来源JASON: { "is_error":0, "undefined_fields":["custom"], "version":3, "count":1, "id":15862, "values":{ "15862":{ "id":15862, "contact_type":"Individual", "contact_sub_type":null, "do_not_email":null,

大家好,这是消息来源JASON:

{
"is_error":0,
"undefined_fields":["custom"],
"version":3,
"count":1,
"id":15862,
"values":{
    "15862":{
        "id":15862,
        "contact_type":"Individual",
        "contact_sub_type":null,
        "do_not_email":null,
        "do_not_phone":null,
        "do_not_mail":null,
        "do_not_sms":null,
        "do_not_trade":null,
        "is_opt_out":null,
        "legal_identifier":null,
        "external_identifier":null,
        "sort_name":"last, first",
        "display_name":"first last",
        "nick_name":null,
        "legal_name":null,
        "image_URL":null,
        "preferred_communication_method":null,
        "preferred_language":"en_US",
        "preferred_mail_format":null,
        "hash":"2b",
        "api_key":"eb",
        "first_name":"Frist",
        "middle_name":"A.",
        "last_name":"Last",
        "prefix_id":null,
        "suffix_id":null,
        "email_greeting_id":null,
        "email_greeting_custom":null,
        "email_greeting_display":null,
        "postal_greeting_id":null,
        "postal_greeting_custom":null,
        "postal_greeting_display":null,
        "addressee_id":null,
        "addressee_custom":null,
        "addressee_display":null,
        "job_title":"Title",
        "gender_id":null,
        "birth_date":null,
        "is_deceased":null,
        "deceased_date":null,
        "household_name":null,
        "primary_contact_id":null,
        "organization_name":"OrgName",
        "sic_code":null,
        "user_unique_id":null
    }
}
}

我有两个问题。正如您可以看到的,“values”下的数字键是在每次返回响应时定义的,其次,我似乎无法访问“values”键内的任何内容

我已尝试使用JSON.Net,但我得到:

无法将“Newtonsoft.Json.Linq.JObject”类型的对象强制转换为“Newtonsoft.Json.Linq.JArray”类型

使用时:

JObject o = JObject.Parse(json);
JArray values = (JArray)o["values"];

获取最内部的数据(这是我所关心的),但我试图通过响应的根级别的所有操作都不起作用。。。你有什么想法吗?

只是一个想法,但试一下var f=o[“值”],看看会有什么影响。JArray可能不是我们想象的那样


尝试改用。

是的,“值”不是数组,而是另一个属性。如果它是一个数组,它应该是:value:[/*这里的stuff*/];感谢您的回复,我尝试了JavaScriptSerializer,但遇到了一点小麻烦。以下是我遇到的情况: