Utf8jsonreader Datetimeoffset Parsing Rfc 3339 Portable May 2026

If you need UTC normalization:

byte[] jsonUtf8 = Encoding.UTF8.GetBytes(@" ""created"": ""2023-12-01T09:15:30+02:00"" "); Utf8JsonReader reader = new Utf8JsonReader(jsonUtf8); while (reader.Read()) utf8jsonreader datetimeoffset parsing rfc 3339

✅ RFC 3339 requires T separator, : in offset, optional fraction. public static class Utf8JsonReaderExtensions If you need UTC normalization: byte[] jsonUtf8 = Encoding

using System; using System.Text.Json; using System.Text.Json.Serialization; // for JsonException public static DateTimeOffset ParseDateTimeOffsetFromReader(ref Utf8JsonReader reader) | | Z not recognized | Some old

DateTimeOffset parsed = ParseDateTimeOffsetFromReader(ref reader); DateTimeOffset utc = parsed.ToUniversalTime(); | Error | Cause | |------------------------------------|-----------------------------------------------------------------------| | JsonException: Expected string | Token is not a string (maybe null or number). | | FormatException on TryParse | Missing T , wrong offset format ( +0530 instead of +05:30 ), wrong fractional seconds. | | Z not recognized | Some old parsers need ToUniversalTime() – not with DateTimeOffset . |

string json = @" ""Timestamp"": ""2023-10-05T14:30:00Z"" "; var evt = JsonSerializer.Deserialize<Event>(json);

public class Event