MessagePack-CSharp
MessagePack-CSharp copied to clipboard
Extra " when calling MessagePackSerializer.ToJson
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
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"
?
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 :
Oh, so typeNameTokenBuilder.ToString()
must emit the surrounding quotes itself. Nice find.
Wanna send the PR?
I would be happy to send the PR if no one else has done it yet
Thank you, @ImanNavidi