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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -