"inputs": {
"input1": {
"value": "abc"
},
"input2": {
"value": "cde"
},
"input3": {
"value": "efg"
},
"input4": {
"value": "ghi"
},
}
Here number of properties in "inputs" may vary. How can I deserialize this into class:
class Inputs
{
public Input[] Values{get; set;}
}
class Input
{
public string input {get; set;}
}
One option is to change the json "inputs" as an array, but I dont have that choice now
Your data matches the following data structure.
public class Data
{
public Dictionary<string, Dictionary<string, string>> Inputs { get; set; }
}
Since you have not mentioned using any library for de/serializing JSON objects, I suggest pretty famous NewtonSoft library for .Net framework.
In you case you can simply deserialize your data with the following snippet.
var data = JsonConvert.DeserializeObject<Data>(YOUR_JSON_STRING);
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