GeezerVison is showing github.com — Extra " when calling MessagePackSerializer.ToJson · Issue #1473 · MessagePack-CSharp/MessagePack-CSharp
Extra " when calling MessagePackSerializer.ToJson #1473
Description
There is an extra " when calling MessagePackSerializer.ConvertToJson for extension code of 100 (typeless)
In MessagePackSerializer.Json.cs at line 435
writer.Write("{\"$type\":\"" + typeNameTokenBuilder.ToString() + "}");
There is an extra " if after type (when no data after type). This will breaks the JSON format. Should be:
writer.Write("{\"$type\":" + typeNameTokenBuilder.ToString() + "}");
Cheers
Tao
Activity
AArnott commented on Jul 28, 2022
Nice catch, @jiatao99. But rather than an extra, wouldn't we say there's one missing?
With you proposed fix, it appears we might generate this JSON: "$type":someTypeName When that's missing quotes. Shouldn't it be "$type":"someTypeName"?
jiatao99 commented on Jul 28, 2022
Here is the output:
{"column1":[{"value1":[{"$type":""System.Decimal"},"1.001"]}],"column2":[{"value2":[null,"text"]}]}
see {"$type":""System.Decimal"} the problem is :""String.Decimal"
whenever you use TypelessFormatter without write anything out in your own formatter, it output "" after :
AArnott commented on Jul 28, 2022
Oh, so typeNameTokenBuilder.ToString() must emit the surrounding quotes itself. Nice find.
Wanna send the PR?
ImanNavidi commented on Aug 24, 2022
I would be happy to send the PR if no one else has done it yet
AArnott commented on Aug 25, 2022
Metadata
Metadata
Development
No branches or pull requestsIssue actions