Is it possible to deserialize a Shape in C# using Json.NET -


edited

is possible deserialize c# object shape attribute?

i have touch object, inherits circle object, inherits obstacle object shape attribute.

i serialize touch object json :

        touch touch = new touch(0.15, 0, 4.05);         touch.shape.stroke = brushes.black;          string json = jsonconvert.serializeobject(touch); 

i deserialize object, using json, :

        touch test = jsonconvert.deserializeobject<touch>(json); 

but access violation line of code.

i think comes shape attribute in obstacle object, declarated :

        protected shape shape;          [jsonproperty(propertyname = "shape")]         public shape shape         {             { return shape; }             set { this.shape = value; }         } 

is there way fix problem?

i found way serialization. deleted shape json serialization using [jsonignore], , create method. need 2 lines instead of 1 create object serialization:

touch test = jsonconverter.deserialize<touch>(json); test.createshape(); 

thank =)


Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -