User1231829591 posted
I have tried to deserialize a JSON array and convert the result into a dotnet object using the JavaScriptSerializer
List<Dom> styleList = (List<Dom>)jSerializer.Deserialize(jsonString, typeof(List<Dom>))
It gave me the error
Type 'System.String' is not supported for deserialization of an array.
After searching the error above online, I came across a post where someone suggested that this problem could be solved using JSON.Net
To my disappointment, JSON.Net also gave me an error. I got the error
Unexpected character encountered while parsing value:
[. Path '[0].Style', line 1, position 22.
Below are my json string which contains escaped double quotes and my C# code to deserialize the JSON string.
string jsonString = "[{\"ID\":\"xx\", \"Style\":[{\"font-size\": \" 2em\", \"color\": \"blue\"}]}]"
Newtonsoft.Json.JsonConvert.PopulateObject(jsonString, styleList);
I had already verified that the json string is valid in jsonlint.com so at the moment I don't know where I went wrong.
Please point out what I am doing incorrectly, thanks in advance for your input.