Reputation: 9630
I have the following text:
Hello <b>User</p>
I am storing it as JSOn string in the database so as to use it later to deserialize it. Below is the JSON string sent to DB in MyProperty column:
{"Html":"Hello <b>User</p>"}
In order to deserialize that string back to my object I am using NewtonSoft.JSON dll.
JsonConvert.DeserializeObject<MyClass>(this.MyProperty);
When I deserialize it I am unable to get "Hello <b>User</p>"
value back, it comes as null.
Note: If I am not string HTML in the JSON string it is returned back while deserializing.
Is there any limitation with html tags in JSON string?
My goal is store html tags in JSON string and get it back.
Edit:
Code of MyClass:
public class MyClass
{
public string Html { get; set; }
public string MyProperty { get; set; }
}
Upvotes: 1
Views: 707
Reputation: 2095
This works:
static void Main(string[] args)
{
string json = "{\"Html\":\"Hello<b>User</p>\" }";
var myClass = JsonConvert.DeserializeObject<MyClass>(json);
}
public class MyClass
{
public string Html { get; set; }
public string MyProperty { get; set; }
}
Upvotes: 1