c# - Easiest way to serialize and deserialize a JSON class that has interface properties? -
i have
class product { public icomponent[] components; } what easiest way deserialize product object json description like
{ "components": [ {"type":"componenta", "key":value} {"type":"componentb", "key":value} ] } ?
thanks.
use json.net
string json = jsonconvert.serializeobject(product); or use javascriptserializer
string json = new javascriptserializer().serialize(product); and reverse operation
var product = jsonconvert.deserializeobject<product>(json) or
var product = new javascriptserializer().deserialize<product>(json)
Comments
Post a Comment