Skip to content

Commit f599a97

Browse files
committed
Write null when ISort or SortKey is null (#4132)
This commit writes null when ISort or ISort.SortKey is null. Simply returning without writing a value can result in incorrectly formatted JSON. Closes #4128 (cherry picked from commit 71c8aae)
1 parent 226ed7a commit f599a97

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/Nest/CommonOptions/Sorting/SortFormatter.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ public ISort Deserialize(ref JsonReader reader, IJsonFormatterResolver formatter
7575
public void Serialize(ref JsonWriter writer, ISort value, IJsonFormatterResolver formatterResolver)
7676
{
7777
if (value?.SortKey == null)
78+
{
79+
writer.WriteNull();
7880
return;
81+
}
7982

8083
writer.WriteBeginObject();
8184
var settings = formatterResolver.GetConnectionSettings();

0 commit comments

Comments
 (0)