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 DataSet
.
My JSONString
is :
{
"Table": [
{
"DisplayVoucherNumber": "A101239Z",
"ActualDate": "08/07/2013",
"AccountName": "shyamal",
"Pcs": "50",
"Weight": "500.000"
}
],
"Table1": [
{
"DisplayVoucherNumber": "R101249B",
"ActualDate": "11/07/2013",
"AccountName": "vipul",
"NetWeight": "90.000",
"Weight": "80.000",
"Difference": "10.000"
},
{
"DisplayVoucherNumber": "R101249B",
"ActualDate": "11/07/2013",
"AccountName": "vipul",
"NetWeight": "500.000",
"Weight": "100.000",
"Difference": "400.000"
}
]
}
We can parse json string to java object using Gson library. We have one json string like Now we will parse json string to java object , So first we create java pojo with filed name id and name String line = ""; //stores the text to parse. StringTokenizer st = new StringTokenizer (line, ":"); String input1 = st.nextToken ();
A JSON parser transforms a JSON text into another representation must accept all texts that conform to the JSON grammar. It may accept non-JSON forms or extensions. An implementation may set the following: set limits on the length and character contents of strings.
Assume you have a text file with a JSON data or a CSV file with a JSON string in a column, In order to read these files and parse JSON and convert to DataFrame, we use from_json () function provided in Spark SQL. 1. Read and Parse a JSON from a TEXT file
1. Read and Parse a JSON from a TEXT file In this section, we will see parsing a JSON string from a text file and convert it to Spark DataFrame columns using from_json () Spark SQL built-in function.
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<DataSet>(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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With