简体   繁体   中英

How to Read Name of array in from JObject in C#

This is the array that i am getting from an api response and i want to read "591460000000352107" this value. this is the key of array and that will be different in every response of api. so how can i read it from Jobject in C# {"response": { "result": [{"591460000000352107": [{"Middle_Name": "","EmailID":"prateek.chauhan@gmail.com","Expertise": ""}]}]}}

var jobj = JObject.Parse(json);
foreach (var result in (jobj["response"]["result"]))
    foreach (var key in (result as JObject).Properties())
        Console.WriteLine(key.Name);

You can iterate over the results and get the name of the keys

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM