简体   繁体   中英

Parse JSON String into List C# VMC

Dear all my brother i have this Json Data enter image description here

0: Object { no: "1", project: "Rosato", job_type: "គ្រឿងសង្ហារឹម", … }
1: Object { no: "2", project: "KPS", job_type: "គ្រឿងសង្ហារឹម", … }

i want to extract it in to c# List or data table please help!

Add Newtonsoft.Json as a reference in your project

string myJsonString = MyMethodToReadJsonAsStringFromDataSource(dataSourceConnection);
IEnumerable<dynamic> myObjects = JsonConvert.DeserializeObject<dynamic>(myJsonString);
foreach(dynamic myObject in myObjects)
{
     // access to your abject
     string no = myObject.no;
     string project = myObject.project;
     string job_type = myObject.job_type;
}

You can replace dynamic with a class you create that maps to your json object so you can have full access to your object at compiler time.

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