Skip to content

[Feature Request]: Add JsonPeek and JsonPatch tasks #9260

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

Open
jrdodds opened this issue Sep 22, 2023 · 3 comments
Open

[Feature Request]: Add JsonPeek and JsonPatch tasks #9260

jrdodds opened this issue Sep 22, 2023 · 3 comments
Labels
backlog blocked Feature Request Priority:2 Work that is important, but not critical for the release triaged

Comments

@jrdodds
Copy link
Contributor

jrdodds commented Sep 22, 2023

Summary

Add support in MSBuild for handling JSON as structured data, roughly equivalent to the XmlPeek, XmlPoke, and XslTransformation tasks for XML.

Background and Motivation

The "Command line evaluation of MSBuild properties" feature will output JSON and JSON has become at least as common as XML but is not supported in MSBuild code.

Proposed Feature

Create JsonPeek and JsonPatch tasks using System.Text.Json.

Like XmlPeek and XslTransformation (and unlike XmlPoke), the JsonPeek and JsonPatch tasks should accept input content as either strings or files.

JsonPeek

JsonPeek would support querying JSON and would depend on a "location path" which should probably conform with the JSONPath Draft RFC. SQL Server has a definition for JSON Path Expressions that seems to follow the RFC and there is a JsonPath.Net implementation.

JsonPeek would be equivalent to XmlPeek.

JsonPatch

JsonPatch would support modifying JSON and would depend on the JSON Patch Proposed Standard. There is a JsonPatch.Net implementation. JSON Patch support in ASP.NET uses Newtonsoft.Json.

The JsonPatch task may be considered to be like XslTransformation. A weakness of XmlPoke is that it uses XPath to identify a node which it essentially can only replace. Because the patch document for JSON is generally simpler than an XSLT, JsonPatch is probably sufficient as an equivalent for both XmlPoke and XslTransformation.

Alternative Designs

No response

@jrdodds jrdodds added Feature Request needs-triage Have yet to determine what bucket this goes in. labels Sep 22, 2023
@rainersigwald
Copy link
Member

IMO the limiting factor here is 1) demand, and 2) JSONPath. If it was in a core .NET library I'd be pretty happy to expose this, but I'm not willing to pull a totally new library in for it. So I consider this blocked on dotnet/runtime#31068.

@jrdodds
Copy link
Contributor Author

jrdodds commented Sep 22, 2023

And the runtime issue is blocking on the spec finalizing. Hopefully eventually this will all come to fruition.

@AR-May AR-May added backlog Priority:2 Work that is important, but not critical for the release and removed needs-triage Have yet to determine what bucket this goes in. labels Sep 26, 2023
@rainersigwald
Copy link
Member

Note JsonPeek was tracked by #8374.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog blocked Feature Request Priority:2 Work that is important, but not critical for the release triaged
Projects
None yet
Development

No branches or pull requests

5 participants