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
The documentation of the WriteXValue methods assumes you're calling the method to append a value to a JSON array when there other usecases, for example when writing converters (see here).
namespaceSystemTextJsonSamples{publicclassDateTimeOffsetJsonConverter:JsonConverter<DateTimeOffset>{publicoverrideDateTimeOffsetRead(refUtf8JsonReaderreader,TypetypeToConvert,JsonSerializerOptionsoptions)=>DateTimeOffset.ParseExact(reader.GetString()!,"MM/dd/yyyy",CultureInfo.InvariantCulture);publicoverridevoidWrite(Utf8JsonWriterwriter,DateTimeOffsetdateTimeValue,JsonSerializerOptionsoptions)=>writer.WriteStringValue(dateTimeValue.ToString(// Call to WriteStringValue"MM/dd/yyyy",CultureInfo.InvariantCulture));}}
Documentation for WriteStringValue:
Writes a string text value (as a JSON string) as an element of a JSON array.
There's also a method call to SetFlagToAddListSeparatorBeforeNextItem() inside the WriteStringValue(ReadOnlySpan<char> value) method.
The text was updated successfully, but these errors were encountered:
What about the call to SetFlagToAddListSeparatorBeforeNextItem() inside WriteStringValue(ReadOnlySpan<char>)? It seems like this method was intended to be for writing values to arrays. Though this hasn't broken anything (as far as its known).
The documentation of the
WriteXValue
methods assumes you're calling the method to append a value to a JSON array when there other usecases, for example when writing converters (see here).Documentation for
WriteStringValue
:There's also a method call to
SetFlagToAddListSeparatorBeforeNextItem()
inside theWriteStringValue(ReadOnlySpan<char> value)
method.The text was updated successfully, but these errors were encountered: