Closed vzsoft closed 10 months ago
NameValueCollection
is not a serializable class, but you can convert it to an Object Dictionary and serialize that:
var text = TypeSerializer.SerializeToString(nvc.ToObjectDictionary());
var deserialize = TypeSerializer.DeserializeFromString<Dictionary<string,object>>(text);
Although when dealing with adhoc or unstructured types like Dictionary<string,object>
we recommend using the JSON Utils in ServiceStack.Common instead, e.g:
var json = JSON.stringify(nvc.ToObjectDictionary());
var fromJson = JSON.parse(json);
fromJson.PrintDump();
The ServiceStack.Text is better suited for de/serializing from known Types.
Describe the issue
Hi, I got error in
TypeSerializer
when Deserialize typeNameValueCollection
and Serialize not correctReproduction
code in C#:
Expected behavior
correct result in SerializeToString
{A:Test1,B:Test2}
System Info
Additional context
sry my english not good
Validations