c# - Deserializing a string with escape characters using JsonConvert -


i have string this:

"[   {     \"someproperty\": 22   }  ]" 

i'm trying deserialize list of known types:

        string toprocess = $@"[{text}]".replace("\n", ",");         toprocess = regex.unescape(toprocess);         list<knowntype> objectlist = jsonconvert.deserializeobject<list<knowntype>>(toprocess); 

however see it's attempting deserialize string containing \" characters, , it's failing cannot deserialize current json object. how deserialize this?

you don't need string toprocess = $@"[{text}]".replace("\n", ",");

string text = @"[   {     \""someproperty\"": 22   }  ]";   text = regex.unescape(text); var objectlist = jsonconvert.deserializeobject<list<knowntype>>(text);  console.writeline(objectlist[0].someproperty);//22 

this code works expected.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -