You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ConvertToJson only seems to handle escaping \r \n \t \f \b - other unicode control codes come through unescaped.
Repro steps
referencing System.Text.Json
publicclassTest{publicstringValue{get;set;}}voidMain(){// write msgpackvartest=new Test {Value="\u0011"};vartestJson= System.Text.Json.JsonSerializer.Serialize(test);varmsgpackData= MessagePack.MessagePackSerializer.ConvertFromJson(testJson);// read msgpackvarmsgpackJson= MessagePack.MessagePackSerializer.ConvertToJson(msgpackData);// throws exception: '0x11' is invalid within a JSON string. The string should be correctly escaped. Path: $.Value | LineNumber: 0 | BytePositionInLine: 10.vartestOut= System.Text.Json.JsonSerializer.Deserialize<Test>(msgpackJson);}
Expected behavior
Escape invalid unicode characters
Actual behavior
invalid unicode characters not escaped
Version used: 2.5.140
Runtime: .NET 7
Additional context
We are using json to read\write between our C# classes and messagepack because the Union attribute isn't really a good solution when there are hundreds of concrete implementations of an interface or set of interfaces.
To get around this currently we need to strip out invalid characters with Regex. See List of controls codes.
System.Text.Json does handle escaping unicode control characters, and is able to deserialize its own output back. It's just when the json comes through MessagePackSerializer.ConvertToJson the characters are not escaped.
The text was updated successfully, but these errors were encountered:
This isn't a JSON serialization library. The JSON support it has is merely included for debuggability so that you can see what's being serialized in what otherwise is an unreadable binary format.
So this is a low priority that we wouldn't get to. If you wanted to send a PR to address this though, we'd review it. But I can't promise we'd merge it.
Bug description
ConvertToJson
only seems to handle escaping\r \n \t \f \b
- other unicode control codes come through unescaped.Repro steps
Expected behavior
Actual behavior
Additional context
Union
attribute isn't really a good solution when there are hundreds of concrete implementations of an interface or set of interfaces.MessagePackSerializer.ConvertToJson
the characters are not escaped.The text was updated successfully, but these errors were encountered: