Support the @encode
TypeSpec decorator with "unixTimestamp"
#3492
Labels
customer-reported
Issues that are reported by GitHub users external to the Azure organization.
DPG
GA-Required
needs-team-attention
Workflow: This issue needs attention from Azure service team or SDK team
Consider the
@encode
decorator in TypeSpec used to specify that autcDateTime
property is encoded as a Unix timestamp:The generated deserialization code for this property would look like this:
The problem is that Unix timestamps are represented as the number of seconds that have elapsed since the Unix epoch (January 1st, 1970, 00:00:00 UTC), but
GetDateTimeOffset()
expects a string. This causes the deserialization code above to fail.More specifically, it seems like .NET's System.Text.Json does not offer first-class support for Unix timestamps; it defaults to ISO 8601-1:2019 instead (which is always a string; not a number). From the documentation, it seems that a custom converter is necessary:
🔗 https://learn.microsoft.com/en-us/dotnet/standard/datetime/system-text-json-support#using-unix-epoch-date-format
The text was updated successfully, but these errors were encountered: