1

I have to the replication.That time have to pass String as JSON

{"Table1" : 
    [
        {"Name" : "MyCustomer","Description" : "cutomer","Status" : "1"},             {"Name" : "Kiraa","Description" : "My","Status" : "1",}
    ]
}

This is my format of JSON result. I want to convert to DataSet.

I have installed JSON.NET library. I am using C#.net

public bool convertJSONToDataSet(string strBusinessUnit, string strExecutiveCode, string strTableName, String jsonContent)
{
    DataSet dataset = JsonConvert.DeserializeObject<String>(jsonContent);
    return true;
}

here this statement is wrong DataSet dataset = JsonConvert.DeserializeObject<String>(jsonContent);.What is the issue. Please tell me how to covert to a JSON string to a Dataset.

1 Answer 1

1

You'd have to create an object to deserialize to.

class Customer
{
    public String Name { get; set; }
    public String Description { get; set; }
    public int Status { get; set; }
}

You can then deserialize objects like this:

Customer customer = JsonConvert.DeserializeObject<Customer>(jsonContent);

As far as I'm concerned, you can then add multiple Customer objects into a list, dataset or whatever you like.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.