Read JSON Data in C#.net

I am pulling data from an API and I believe it is returned as a JSON string, how can I read certain data from the string ?  There are rows of data I want to loop through and put in a datatable, but can not figure out how to extract the data.

I have attached 3 files - the first 2 is the data I want to access, the third is the name of the columns.

Path to Column NamesWhere the data is - Label and Value are two fields inside I want to access.Path To Data
chelsea17Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

leakim971PluritechnicianCommented:
check a look to that online tools : http://json2csharp.com/
I will create classes reprensenting your JSON object to use with : https://github.com/JamesNK/Newtonsoft.Json/

for example :
[{"ok":"lol","ik":[{"a":1},{"a":1},{"a":4}]}]

Open in new window

give :
public class Ik
{
    public int a { get; set; }
}

public class RootObject
{
    public string ok { get; set; }
    public List<Ik> ik { get; set; }
}

Open in new window

chelsea17Author Commented:
once i create the class how to call the values i want ?
leakim971PluritechnicianCommented:
in my example, if I want the ok value (which is "lol")

                string strReportData = "[{\"ok\":\"lol\",\"ik\":[{\"a\":1},{\"a\":1},{\"a\":4}]}]";
                JsonSerializer serializer = new JsonSerializer();

                RootObject reportData = (RootObject)serializer.Deserialize(strReportData, typeof(RootObject));

                string strOK = reportData.ok; // "lol"

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
chelsea17Author Commented:
i get the error - Argument 1: cannot convert from 'string' to 'System.IO.TextReader'      

on this Deserialize(reportData, typeof(Rootobject));


this is the code

            var reportData = restResponse.Content;

            JsonSerializer serializer = new JsonSerializer();

            Rootobject datafromreport = (Rootobject)serializer.Deserialize(reportData, typeof(Rootobject));

            string strOK = datafromreport.allData.ToString();

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.