Open mcaden opened 2 years ago
This is likely a duplicate of https://github.com/dotnet/runtime/issues/53539.
I don't think so... I'm using Newtonsoft and I've implemented the proper JsonConverters. Judging by https://github.com/dotnet/aspnetcore/blob/main/src/Features/JsonPatch/src/Internal/ConversionResultProvider.cs which is what tracing ApplyTo
leads to it doesn't look like there's an easy way to specify the contract resolver for that specific property without messing with JsonPatch's internals.
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.
A workaround I used is to format payload value YYYY-MM-DD
rather than use ISO8601 YYYY-MM-DDT00:00:00Z
For example,
PATCH [{op: "replace", path: "/example", value: "2024-01-02"}]
=> succeeds
PATCH [{op: "replace", path: "/example", value: "2024-01-02T00:00:00"}]
=> fails with exception "The value '01/02/2024 00:00:00' is invalid for target location."
Is there an existing issue for this?
Is your feature request related to a problem? Please describe the problem.
DateTime
works fine from JsonPatchDocument. However,DateOnly
will not parse from a string and you can't set its year/month/day from properties so you can't build up a new object and "patch" it.Describe the solution you'd like
DateOnly
should parse via JsonPatch from an ISO8601 date string that JavaScript uses.Alternatively, even a simple
YYYY-MM-DD
.Additional context
The specific issue is that when sending a date string as an ISO 8601 value to be patched into a
DateOnly
object such as2022-03-17T00:00:00.000Z
theApplyTo
call fails withThe value '3/17/2022 12:00:00 AM' is invalid for target location.