ServiceStack JSONSerializer and HashSet <x>
We have this code:
// using ServiceStack JSONSerializer string typeInfoString = JsonSerializer.SerializeToString<Type>(typeof(HashSet<string>)); // yields "System.Collections.Generic.HashSet`1[[System.String, mscorlib]], System.Core" // this string is the same thing, so it probably valid json string jsonTypeInfo = typeof(HashSet<string>).ToJson(); // this should work, I feel like Type desType = JsonSerializer.DeserializeFromString<Type>(jsonTypeInfo); // but desType ends up being null :( Is there any ServiceStack to get HashSet type information?
+4
2 answers
This seems like an error in ServiceStack.Text. I traced this problem to the AssemblyTypeDefinition.cs 17 line (at the time of this writing). Incoming typeDefinition is "System.Collections.Generic.HashSet`1 [[System.String, mscorlib]], System.Core", and TypeDefinitionSeperator is ",", resulting in the line being split into the first instance "," instead of the second, where should he. Simulating the correct line break (in the debugger) returns the correct result from your code.
You might want to portray this as a bug for the ServiceStack community.
+2