I have a class with multiple properties. One property containes properly formed JSON
.
Something like:
public MyClass {
public string Val {get;set;}
public string AlreadyJson {get;set;} // properly formed JSON
}
Now I need to send this object to some external api
using PostAsync
. To do this I have to serialize MyClass
object to JSON
first.
However, as AlreadyJSON
property is already serialized (it is already json), I need to ignore it (by ignore I mean - I still have to include it into resulting json, but I do not need to serialize it).
The same should apply to deserialization. I believe it should be easy with some attribute to MyClass
, but unfourtunately I could not achieve this. For instance, adding JsonIgnore
would simple ignore property and would not include it into resulting string.
Any solution would be good: using Newtonsoft
or using built in DataContractJsonSerializer