liubiao4123 / servicestack

Automatically exported from code.google.com/p/servicestack
0 stars 0 forks source link

Unable to serialize C# structures #42

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.Created one custom struct (like C# Point)
2.Created instances for my structure
3.Tried to serialize using JsonSerializer and TypeSerializer

What is the expected output? What do you see instead?
 It hols the type information instead data

Please provide any additional information below.
 Attached sample code

Original issue reported on code.google.com by rms...@gmail.com on 12 Oct 2010 at 5:00

Attachments:

GoogleCodeExporter commented 8 years ago
Hi,

The Serializers handle ValueTypes/Structs differently, You will need to 
implement ToString(), and either provide a static TStruct.Parse(string) method 
or a string constructor (e.g. ctor(string)).

See example here: http://bit.ly/c6XKVO

This was done because many structs contains field data they want to serialize. 
It also allows you to do a more compact serialization for structs. 

Original comment by demis.be...@gmail.com on 12 Oct 2010 at 5:13

GoogleCodeExporter commented 8 years ago

Thanks demis.

I got it.
I have opened this because "Json.NET" is doing the same thing without 
implementing ToString() and Parse() Methods.

Original comment by rms...@gmail.com on 13 Oct 2010 at 3:53

GoogleCodeExporter commented 8 years ago
No probs :)

Original comment by demis.be...@gmail.com on 13 Oct 2010 at 7:06