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

sql - VB.NET Operand type clash: date is incompatible with int error -

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

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -