How to parse a JSONString To Dataset?

后端 未结 6 1690
我寻月下人不归
我寻月下人不归 2020-12-03 15:38

I am creating a C# Application using Web Services. In my Web Services I\'m using a JSONString data. But I\'m not able to convert this string into a DataSe

6条回答
  •  生来不讨喜
    2020-12-03 16:32

    Your question is not very clear. I guess that what you would like to do is get back an object that could be mapped to you data set after deserializtion. Something like

    DataSet myDataSet= JsonConvert.DeserializeObject(jsonstring)
    

    And you keep going coding with you dataset. like accessing datatables inside the dataset.

    If it's what you want to achieve and don't want to use your own POCO as suggested by previous answers. You might need to create a Typed DataSet before

    Given an XML Schema that complies with the XML Schema definition language (XSD) standard, you can generate a strongly typed DataSet using the XSD.exe tool provided with the Windows Software Development Kit (SDK). More info on strongly typed Dataset

    This will allow you to use the strongly typed dataset using the Deserialize method.

    Bare in mind that you have to mimic your JSon Structure in the XML Schema. in order to have something compatible with your JSon Structure at the end.

提交回复
热议问题