diff --git a/src/Squidex.Infrastructure/Log/IArrayWriter.cs b/src/Squidex.Infrastructure/Log/IArrayWriter.cs index 127fcb157..a8159ac7d 100644 --- a/src/Squidex.Infrastructure/Log/IArrayWriter.cs +++ b/src/Squidex.Infrastructure/Log/IArrayWriter.cs @@ -21,6 +21,6 @@ namespace Squidex.Infrastructure.Log IArrayWriter WriteValue(DateTime value); IArrayWriter WriteValue(DateTimeOffset value); - IArrayWriter WriteObject(string property, Action objectWriter); + IArrayWriter WriteObject(Action objectWriter); } } \ No newline at end of file diff --git a/src/Squidex.Infrastructure/Log/JsonLogWriter.cs b/src/Squidex.Infrastructure/Log/JsonLogWriter.cs index b35f9d830..8e61631cb 100644 --- a/src/Squidex.Infrastructure/Log/JsonLogWriter.cs +++ b/src/Squidex.Infrastructure/Log/JsonLogWriter.cs @@ -156,9 +156,8 @@ namespace Squidex.Infrastructure.Log return this; } - IArrayWriter IArrayWriter.WriteObject(string property, Action objectWriter) + IArrayWriter IArrayWriter.WriteObject(Action objectWriter) { - jsonWriter.WritePropertyName(property); jsonWriter.WriteStartObject(); objectWriter?.Invoke(this); diff --git a/tests/Squidex.Infrastructure.Tests/Log/JsonLogWriterTests.cs b/tests/Squidex.Infrastructure.Tests/Log/JsonLogWriterTests.cs index 606b31eb5..f39274344 100644 --- a/tests/Squidex.Infrastructure.Tests/Log/JsonLogWriterTests.cs +++ b/tests/Squidex.Infrastructure.Tests/Log/JsonLogWriterTests.cs @@ -114,6 +114,14 @@ namespace Squidex.Infrastructure.Log Assert.Equal(@"{""property"":[""2.16:30:20.1000000""]}", result); } + [Fact] + public void Should_write_object_in_array() + { + var result = sut.WriteArray("property1", a => a.WriteObject(b => b.WriteProperty("property2", 120))).ToString(); + + Assert.Equal(@"{""property1"":[{""property2"":120}]}", result); + } + [Fact] public void Should_write_datetimeoffset_value() { @@ -131,7 +139,7 @@ namespace Squidex.Infrastructure.Log Assert.Equal($"{{\"property\":[\"{value.ToString("o")}\"]}}", result); } - + [Fact] public void Should_write_nested_object() {