-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add list option to format output as json #2032
Comments
We've discussed having "--json" as an argument to do exactly this, but hadn't created an issue for it :) |
I am playing with it right now and thought how good it would be to have the |
It's strange a |
@WillPittenger we've been open source since the very first preview in 2020. There has been a mixture of priorities, and the overall roadmap philosophy is shared. This simply wasn't something the community wanted as a top priority. Looking at the top-most 👍Issues:
Supporting PowerShell as a native interface will expose rich objects for many of the scripted/automated scenarios being asked for by many IT Professionals, as well as many developers and power users. We've been considering exposing the CLI output as JSON as an additional value add since most of the work would have to be done in order to support a native PowerShell experience. |
I agree 100% with PowerShell support! The reason JSON output was requested is because it is readily consumed by PowerShell. |
JSON output would be much easier for our projects. Scripts would become much simpler 😇 |
Not sure if everyone is aware of this already or not, but for those that are looking to get winget results in JSON format, I was looking for the same and came upon the winget.run REST API which serves my purposes fine for now until winget itself is able to provide this functionality. For my own use case, I only needed JSON for search results rather than for installed packages, so in my case just directly using the API alone satisfies my needs, but it could also potentially be useful for those looking to get JSON for installed packages as well if you're willing to jump through an additional hoop. The API doesn't know what packages you have installed, but if you use the winget cli itself to get just a list of your installed package ids, you can then pass those ids directly into the winget.run API which will get you the JSON for all of your installed packages. Not ideal, but perhaps this may be helpful for some others until the eventual time when the winget cli will inevitably satisfy all of these use cases itself once further development is completed. https://docs.winget.run/docs/introduction/ https://github.com/winget-run/wingetdotrun EDIT: Oops, someone pointed out to me that this may be problematic for getting JSON for installed packages as there seems to be no way to actually pass in more than one package id with a single call to the API. Sorry about that. |
Instead of |
Winget has a different type of error-code structure, and lacks any kind of "export as data" functionality. Hopefully this changes in the future, letting us get more information from the cli api (microsoft/winget-cli#2032)
If you need to process data returned from the winget cli output, you can use example usage: # Install module for winget
Install-Package Microsoft.WinGet.Client
# Show All installed packages
Get-WinGetPackage | Out-GridView |
In addition to the PowerShell module, COM APIs are also available for object-based integration. |
Description of the new feature / enhancement
The list command outputs a human readable table of installed packages that is not easy to parse by an external tool. Formatting the list output as JSON by adding a --JsonOutput command line option would be very useful.
Proposed technical implementation details
No response
The text was updated successfully, but these errors were encountered: