liubiao4123 / servicestack

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

Deserialization (Json/Type serializer) problem with Collection type (Queue,Stack,BitArray,Hashtable) #56

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
*What steps will reproduce the problem?*
1. Serialize one of this type : Queue<T>, Stack<T>, BitArray, Hashtable
2. Try to deserialize !

*What is the expected output? What do you see instead?*
The serialization works fine, but when attempting to deserialize an exception 
is thrown.
For generic types Queue and Stack :
_Unable to cast object of type 
'System.Collections.Generic.List`1[System.String]' to type 
'System.Collections.Generic.Stack`1[System.String]'.
   at ServiceStack.Text.JsonSerializer.DeserializeFromString[T](String value)_
For types BitArray, Hashtable :
_Incorrect number of arguments supplied for call to method 'Void 
set_Item(System.Object, System.Object)
   at ServiceStack.Text.Json.JsonReader`1.Parse(String value)
   at ServiceStack.Text.JsonSerializer.DeserializeFromString[T](String value)_

*What version of the product are you using? On what operating system?*
ServiceStack.Text v1.77m

Original issue reported on code.google.com by Baptiste...@gmail.com on 4 Feb 2011 at 10:11

GoogleCodeExporter commented 8 years ago
Hi,

ServiceStack.Text no longer lives here, its now moved to:
https://github.com/mythz/ServiceStack.Text/

Can you please send all future issues (and preferably pull requests) to:
https://github.com/mythz/ServiceStack.Text/issues

I've added support to Queue<T>, Stack<T> in the latest release (v1.80+) which 
you can download from:
https://github.com/mythz/ServiceStack.Text/downloads

I'm not going to support Hashtable since its a legacy structure and instead of 
BitArray you should use byte[] which is supported.

Thanks,
Demis

Original comment by demis.be...@gmail.com on 5 Feb 2011 at 1:12

GoogleCodeExporter commented 8 years ago
Hi,

Thanks a lot for the answer, sorry to have post here instead of github.
The Queue<T> and Stack<T> support is exactly what I needed. I only post the 
BitArray and Hastable issue because I found it.

Thanks again,
Baptiste

Original comment by Baptiste...@gmail.com on 5 Feb 2011 at 11:45

GoogleCodeExporter commented 8 years ago
Cool no worries, I was surprised that Queue<T>/Stack<T> weren't automatically 
supported by virtue of being ICollection<T>s (which I just found out their not 
:)

Anyway tests are also included so it should work without any issues. Although 
if you happen to find any you know where to send them to :)

Original comment by demis.be...@gmail.com on 5 Feb 2011 at 12:01

GoogleCodeExporter commented 8 years ago
Humm I just test with the v1.80+, and Queue<T>/Stack<T> deserialization is 
working fine, but Queue without Generic type isn't working.
Should I post a new issue on Github or you are not going to support it as 
Hashtable ?

By the way, nice work =]

Original comment by Baptiste...@gmail.com on 5 Feb 2011 at 10:11