Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JsonPatchDocument should use System.Text.Json #24333

Open
xperiandri opened this issue Jul 27, 2020 · 61 comments
Open

JsonPatchDocument should use System.Text.Json #24333

xperiandri opened this issue Jul 27, 2020 · 61 comments
Assignees
Labels
affected-few This issue impacts only small number of customers area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-json-patch severity-minor This label is used by an internal tool
Milestone

Comments

@xperiandri
Copy link

Related to #16968
Will you accept pull-request with this feature?

@xperiandri
Copy link
Author

I propose to:

@mkArtakMSFT mkArtakMSFT added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates feature-json-patch enhancement This issue represents an ask for new feature or an enhancement to an existing one labels Jul 27, 2020
@mkArtakMSFT mkArtakMSFT added this to the Backlog milestone Jul 27, 2020
@ghost
Copy link

ghost commented Jul 27, 2020

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.

@mkArtakMSFT
Copy link
Member

Thanks for your willingness to help.
We would prefer to think more about this first and decide on the direction we want to go before asking for help.

@null-d3v
Copy link

There have been many issues reported regarding json patch still being tied to Newtonsoft.Json deserialization. The issues are caused by adverse effects of the association, or directly indicating dissatisfaction with it:
#12994
#13938
#14035
#16968
#22216
#22620

System.Text.Json has merits over Newtonsoft.Json purported by Microsoft with indication to fully remove the Json.NET dependency from ASP.NET Core.

Thus, we want to remove the Json.NET dependency from ASP.NET Core 3.0, so that customers can choose which version to use, without fearing they might accidentally break the underlying platform.

Configuration of json patch to only use Newtonsoft.Json processing for patch requests is contrived, requiring building an entire separate service collection with complete MVC to pull an input formatter with appropriate DI.

To indicate the intent of complete System.Text.Json support in ASP.NET Core, not have the support, and then to consistently delay in the face of consistent issues is extremely discouraging:
#12994 (comment)
#14035 (comment)
#14035 (comment)
#16968 (comment)

@erwan-joly
Copy link

I wonder if the easiest way to have that feature added wouldn't be to fork the feature project https://github.com/dotnet/aspnetcore/commits/master/src/Features/JsonPatch in another repo
make it works without newtonsoft
then ask dotnet/aspnetcore if they want to replace newtonsoft json patch to that one

@SteveSandersonMS SteveSandersonMS added affected-few This issue impacts only small number of customers severity-minor This label is used by an internal tool labels Oct 6, 2020 — with ASP.NET Core Issue Ranking
@ghost
Copy link

ghost commented Nov 11, 2020

This is bit of an annoying oversight. Any news?

@erwan-joly
Copy link

https://github.com/gregsdennis/json-everything

@natelaff
Copy link

natelaff commented Jan 14, 2021

+1, Everything is moving to System.Text.Json... Swagger, Refit, etc... this needs to be addressed.

@sulmar
Copy link

sulmar commented Jul 23, 2021

Do you have any plans to use JsonPatchDocument with System.Text.Json in upcoming .NET 6 ?
It will be very handy in Minimal API.

@Havunen
Copy link

Havunen commented Aug 23, 2021

Has anybody found good open source json patch library for system text json?

@erwan-joly
Copy link

Has anybody found good open source json patch library for system text json?

#24333 (comment)

@pranavkm pranavkm added old-area-web-frameworks-do-not-use *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels and removed area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels Oct 19, 2021
@winromulus
Copy link

A lot of projects have dropped support for Newtonsoft.Json (especially for annotations) in favor of System.Text.Json
Some projects, like the Kubernetes C# client rely heavily on support for JSON Patch.
Is it possible to re-evaluate the priority on this in light of increased requests for support on this topic? It's been years since it was considered low-priority since few projects had been ported to System.Text.Json at the time.

@Grizzlly
Copy link

@pranavkm I think this is worth looking into. It is a bummer that we have to rely on Newtonsoft.

The code in the documentation throws ASP0000 warning. This should be mentioned in the docs imo.

@beachwalker
Copy link

Still a issue? Keeps us from switching.

@Grizzlly
Copy link

Still a issue? Keeps us from switching.

Yes.

@rqueizan
Copy link

rqueizan commented Mar 7, 2022

Install this package Microsoft.AspNetCore.Mvc.Formatters.Json for System.Text.Json

@erwan-joly
Copy link

Install this package Microsoft.AspNetCore.Mvc.Formatters.Json for System.Text.Json

This seems to use newtonsoft from Microsoft.AspNetCore.JsonPatch

@rqueizan
Copy link

rqueizan commented Mar 7, 2022

Install this package Microsoft.AspNetCore.Mvc.Formatters.Json for System.Text.Json

This seems to use newtonsoft from Microsoft.AspNetCore.JsonPatch

image

image

image

I am not using Newtonsoft.Json!

@erwan-joly
Copy link

Install this package Microsoft.AspNetCore.Mvc.Formatters.Json for System.Text.Json

This seems to use newtonsoft from Microsoft.AspNetCore.JsonPatch

image

image

image

I am not using Newtonsoft.Json!

Indirectly your are https://www.nuget.org/packages/Microsoft.AspNetCore.JsonPatch/

@captainsafia captainsafia added area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc and removed old-area-web-frameworks-do-not-use *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels labels Jun 20, 2023
@tjmcdonough
Copy link

@Havunen solution works very well. I have just given the GitHub project a star :) Highly recommend we all use this until Microsoft comes up with a solution

@zinov
Copy link

zinov commented Aug 17, 2023

I'm looking for better implementation yet.

I thought about using my own implemention of IModelBinder but in the minimal api seems not to be supported.

In .NET 7 for Custom Binding we can use only TryParse or BindAsync methods: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/minimal-apis/parameter-binding?view=aspnetcore-7.0#custom-binding

It is easy to add for own model but not for JsonPatchDocument.

this is something that should be coming with the framework instead of doing a custom model binder to map all parameters. Microsoft should follow the standard: https://datatracker.ietf.org/doc/html/rfc6902

@Arkovski
Copy link

Arkovski commented Apr 17, 2024

mkArtakMSFT you're thinking quite a lot, maybe time to do anything? :)

@rohitvipin
Copy link

Happy 4 year anniversary for a very important issue :(

@DanielThyselius
Copy link

Bugs and requests against it just seem to get backlogged (including two of mine) despite very little activity in that area. I think JsonPatch sharing a backlog with core ASP.NET Core means it'll always be deprioritised unless a conscious push is made

Can you try out SystemTextJsonPatch? I believe I have fixed both the issues you reported about AspNetCore.JsonPatch. I know its not the official Microsoft package but personally I just needed a package that works and does not depend on Newtonsoft.

I've tried this out and it worked out of the box, brilliant work!

@lincoln42
Copy link

Its niggling and neglected issues like this that cause many enterprise projects to abandon using the .Net framework entirely and move other API frameworks like Python FastAPI (https://medium.com/@david.danier/how-to-handle-patch-requests-with-fastapi-c9a47ac51f04) or Java SpringBoot 3 (https://www.baeldung.com/spring-rest-json-patch).

.Net is regarded as incomplete for enterprise work due to such issues and makes advocating for it's continued use in the enterprise really difficult when competing frameworks offer a friction free developer experience.

@mkArtakMSFT mkArtakMSFT self-assigned this Jan 21, 2025
@davidfowl davidfowl marked this as a duplicate of #52366 Feb 1, 2025
@mikekistler
Copy link
Contributor

This issue has been open for a long time and has many comments and upvotes, so we're evaluating this as a potential feature for .NET 10.

There are a number of third party packages, several mentioned in this issue, that provide support for JSON Patch with System.Text.Json. In light of that, we'd like to hear from users whether it's necessary to add this support into the core framework or if support with a third party package is acceptable.

Bear in mind that adding this support to the core framework will require resources that could otherwise be applied to other features. So think of the most important feature you're hoping for in .NET 10, and if built-in JSON Patch support is more important than that, we definitely want to hear that perspective. And we also want to hear the contrary -- that support from a third party package is perfectly fine for you.

Please share your views on this question below, and especially the "why" behind your views, so we can apply our resources in the most impactful way for .NET users.

Thank you!

@carlblanchard
Copy link

Hi Mike,

I strongly believe that the PATCH verb and an Operation object are long overdue to be included in .NET.
While I understand that PATCH was introduced later than other HTTP verbs, it is still an RFC standard, and its official implementation in .NET is long overdue. Standardising it would greatly improve consistency and best practices across the ecosystem.

https://datatracker.ietf.org/doc/html/rfc6902#section-4.1

@stevendarby
Copy link

stevendarby commented Feb 7, 2025

If you have limited resources, consider spending less on Aspire- it doesn't seem to be as popular.

Aspire.Hosting.AppHost
image

Microsoft.AspNetCore.JsonPatch
image

@lincoln42
Copy link

lincoln42 commented Feb 9, 2025 via email

@OpenSpacesAndPlaces
Copy link

OpenSpacesAndPlaces commented Feb 10, 2025

I think the frustration the community has with feature requests like this is that there is seemingly more mental effort spent punting vs. the time it would take to add the missing element in. To be fair though, this is hardly a problem unique to .Net Core. If you've been in software development long enough you'd had at least one "why we shouldn't bother meeting" that runs longer and uses more resources than implementation time to build something.

I get the counter argument that if there is no vetting, that leads to system bloat and what I'll call the "rural road problem" where there is more to maintain than resources can afford.

TLDR - Low effort, low maintenance, high reward features- there has to be a more efficient path to vet these and get them in.

@zinov
Copy link

zinov commented Feb 10, 2025 via email

@lincoln42
Copy link

lincoln42 commented Feb 11, 2025 via email

@ChrisSimmons
Copy link

ChrisSimmons commented Feb 17, 2025

This issue has been open for a long time and has many comments and upvotes, so we're evaluating this as a potential feature for .NET 10.

There are a number of third party packages, several mentioned in this issue, that provide support for JSON Patch with System.Text.Json. In light of that, we'd like to hear from users whether it's necessary to add this support into the core framework or if support with a third party package is acceptable.

Bear in mind that adding this support to the core framework will require resources that could otherwise be applied to other features. So think of the most important feature you're hoping for in .NET 10, and if built-in JSON Patch support is more important than that, we definitely want to hear that perspective. And we also want to hear the contrary -- that support from a third party package is perfectly fine for you.

Please share your views on this question below, and especially the "why" behind your views, so we can apply our resources in the most impactful way for .NET users.

Thank you!

@mikekistler It's great to see that Microsoft is looking at this. I would prefer to see first-class support from Microsoft in the core framework and I'll try to break down my "why" reasoning as simply as possible to meet what you're looking for to justify dedicating resources.

JSON Patch support is more important than [insert other possible new .NET features]

Why do I think the functionality itself is important? JSON Patch support is highly important to me, and specifically more important than other possible .NET features, because I work in REST web services all-day-every-day. This means an implementation of PATCH that meets an RFC standard is critical. This isn't a corner case or nice-to-have feature. PATCH is foundational and we've had an RFC available to describe this for going on 12 years now.

Stability / Longevity of a solution

Why do I think Microsoft should provide it in the core framework as opposed to relying on third-party solutions? Simply put here, at least from my point of view, Microsoft has done a fantastic job of keeping stability in their APIs for long periods of time. I'm not saying you guys are perfect but overall you're d*** good.

But I'm not saying that to flatter. A lot of my feelings on this point have to do with recent failings in trust for widely-used packages. I'm thinking specifically of Moq and FluentAssertions. My examples there are nice-to-haves ultimately yet still caused great consternation when they changed their license or inserted some sketchy functionality. Something this critical, IMHO, needs to be provided by a funded organization that is highly unlikely to rug-pull like this.

Hope that helps your analysis of this issue.

@mikekistler mikekistler removed the area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions label Feb 19, 2025
@abratv
Copy link

abratv commented Feb 20, 2025

i think the team need better product manager
Http patch should be basic stuff included in the core framework
The priority went to Aspire (nice to have) and "fancy" stuff with Blazor
do we really need to wait for .net 10 for this?

@davidfowl
Copy link
Member

davidfowl commented Feb 20, 2025

I’d recommend keeping the discussion on topic. Don’t attack the people on the team, and follow the code of conduct. There are lots of ways to share frustration without sinking to ad hominem attacks. Yes we’re looking at the cost of implementing this and yes you’re have to wait for .NET 10.

If that’s too long a wait @abratv feel free to use the package referenced several times on this very long thread. https://github.com/Havunen/SystemTextJsonPatch

@danroth27 danroth27 changed the title JsonPatchDocument should use System.Text.Json in ASP.NET vNext JsonPatchDocument should use System.Text.Json Feb 25, 2025
@mikekistler
Copy link
Contributor

Thanks to all who shared your thoughts on this issue. We posted the roadmap for .NET 10 earlier this week and we have included this in the proposed set of features for ASP.NET. As always, the roadmap is "an aspirational list of what we hope to get to", but given the level of frustration with this issue we are very hopeful that we can deliver this feature in .NET 10.

@lincoln42
Copy link

lincoln42 commented Feb 28, 2025 via email

@carlblanchard
Copy link

@mikekistler this is great :) Thank you.

@zinov
Copy link

zinov commented Feb 28, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affected-few This issue impacts only small number of customers area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-json-patch severity-minor This label is used by an internal tool
Projects
None yet
Development

No branches or pull requests