Different behavior between Verify.SystemJson and Verify.NewtonsoftJson for empty property
Closed this issue · 3 comments
gpetrou commented
Describe the bug
Use the following with Verify.SystemJson:
[Fact]
public Task TestEmpty() =>
Verify(JsonNode.Parse("""
{
"empty":{}
}
"""));
It results in:
{
empty: {}
}
Use the following with Verify.NewtonsoftJson:
[Fact]
public Task TestEmpty() =>
Verify(JObject.Parse("""
{
"empty":{}
}
"""));
It results in:
{
{}
}
The problem seems to be happening when
is called with an empty collection.It would be nice if Verify.NewtonsoftJson
could produce the same result as Verify.SystemJson
. I checked the settings and I don't see an option to fix that. Perhaps I missed it?
SimonCropp commented
try this
[Fact]
public Task TestEmpty() =>
Verify(
JObject.Parse(
"""
{
"empty":{}
}
"""))
.DontIgnoreEmptyCollections();
SimonCropp commented
or
[ModuleInitializer]
public static void Initialize() =>
VerifierSettings.DontIgnoreEmptyCollections();
gpetrou commented
Oh, I see. OK thanks. I was only looking at the JSON settings.