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
It seems that JsonEventEmitter doesn't set the eventInfo.Style correctly for DateTime, resulting in the date/time string ending up in single quotes what is not JSON compatible. For example:
using System;
using YamlDotNet.Serialization;
namespace YamlDotNetDateTimeBugReport
{
class TestData
{
public DateTime Date => DateTime.Now;
}
class Program
{
static void Main(string[] args)
{
ISerializer jsonSerializer = new SerializerBuilder()
.JsonCompatible()
.Build();
Console.WriteLine(jsonSerializer.Serialize(new TestData()));
}
}
}
results in
{"Date": '2021-02-24T10:20:12.3763590+01:00'}
The fix is simple, just adding eventInfo.Style = ScalarStyle.DoubleQuoted;
under case TypeCode.DateTime in JsonEventEmitter.cs
The text was updated successfully, but these errors were encountered:
It seems that JsonEventEmitter doesn't set the
eventInfo.Style
correctly forDateTime
, resulting in the date/time string ending up in single quotes what is not JSON compatible. For example:results in
{"Date": '2021-02-24T10:20:12.3763590+01:00'}
The fix is simple, just adding
eventInfo.Style = ScalarStyle.DoubleQuoted;
under
case TypeCode.DateTime
in JsonEventEmitter.csThe text was updated successfully, but these errors were encountered: