I have the same problem as this question in that I want to deserialize dynamic json data. In other words, the keys: "error1, etc are dynamic. In my case:
{
"errors" : {
"error1" : {
"name" : "connection error",
"location" : "CPU board",
"id" : "E0001"
},
"warning2" : {
"name" : "Value not formatted",
"location" : "Controller",
"id" : "W005"
},
"info4" : {
"name" : "Attention to temperature",
"location" : "Heater",
"id" : "I008"
}
}
}
In the question, the answer uses JsonConvert
to deserialize into a dictionary. I have found also here that something similar can be done using JavascriptSerializer
.
I suppose that I can use those to solve my problem but my question is, can I do this too using DataContractJsonSerializer
?