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

Request to Add an Option to Provide Winget Output in Dictionary Format #5264

Closed
Xeon-774 opened this issue Mar 1, 2025 · 3 comments
Closed
Labels
Issue-Feature This is a feature request for the Windows Package Manager client. Resolution-Duplicate Issue is a duplicate

Comments

@Xeon-774
Copy link

Xeon-774 commented Mar 1, 2025

Description of the new feature / enhancement

Implement an option to output results in a structured dictionary format.
Currently, winget outputs search results in a matrix format suitable for terminal display. By introducing an option to provide output in a structured dictionary format, users can obtain parseable data more easily.

Additional Notes:
This issue highlights three distinct problems observed from the current output behavior.
Related URLs:

Proposed technical implementation details

Expected Behavior:
An option to enable structured dictionary format output.
For example, executing winget search --return-dict softwarename should return output in the following format:

[
    {"Name": "Vivaldi Browser", "Id": "XP99GVQDX7JPR4", "Version": "Unknown", "Match": None, "Source": "msstore"},
    {"Name": "Vivaldi", "Id": "Vivaldi.Vivaldi", "Version": "7.1.3570.58", "Match": "ProductCode: vivaldi", "Source": "winget"},
    {"Name": "Vivaldi (Snapshot)", "Id": "Vivaldi.Vivaldi.Snapshot", "Version": "7.2.3617.3", "Match": "ProductCode: vivaldi", "Source": "winget"}
]

Actual Behavior:
Currently, there is no option to output results in a structured dictionary format.

Name               Id                       Version     Match                Source
------------------------------------------------------------------------------------
Vivaldi Browser    XP99GVQDX7JPR4           Unknown                          msstore
Vivaldi            Vivaldi.Vivaldi          7.1.3570.58 ProductCode: vivaldi winget
Vivaldi (Snapshot) Vivaldi.Vivaldi.Snapshot 7.2.3617.3  ProductCode: vivaldi winget

Reproduction Steps:
execute the following commands in PowerShell:
winget search vivaldi
winget search vivaldi > output.txt

Environment:
OS: Windows 10 (Build 19045)
Winget Version: v1.10.320
PowerShell Version: 5.1.19041.5486
VSCode Version: 1.97.2
Terminal: VSCode Integrated Terminal (PowerShell)

Desired Features/Improvements:
Provide an option to output results in a structured dictionary format for easier parsing.
Example: winget search --return-dict *softwarename*

@Xeon-774 Xeon-774 added the Issue-Feature This is a feature request for the Windows Package Manager client. label Mar 1, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Triage Issue need to be triaged label Mar 1, 2025
@mdanish-kh
Copy link
Contributor

@Xeon-774 Have you tried out WinGet's PowerShell module? You can use a command like the following to get the desired JSON:

Find-WinGetPackage -Name vivaldi | ConvertTo-Json
Sample output
[
  {
    "Version": "Unknown",
    "Name": "Vivaldi Browser",
    "Id": "XP99GVQDX7JPR4",
    "IsUpdateAvailable": false,
    "Source": "msstore",
    "AvailableVersions": [
      "Unknown"
    ]
  },
  {
    "Version": "7.1.3570.58",
    "Name": "Vivaldi",
    "Id": "Vivaldi.Vivaldi",
    "IsUpdateAvailable": false,
    "Source": "winget",
    "AvailableVersions": [
      "7.1.3570.58",
      "7.1.3570.54",
      "7.1.3570.50",
      "7.1.3570.48",
      ....
    ]
  },
  {
    "Version": "7.2.3617.3",
    "Name": "Vivaldi (Snapshot)",
    "Id": "Vivaldi.Vivaldi.Snapshot",
    "IsUpdateAvailable": false,
    "Source": "winget",
    "AvailableVersions": [
      "7.2.3617.3",
      "7.2.3616.4",
      "7.2.3610.4",
      "7.2.3597.3",
      ....
    ]
  }
]

@microsoft-github-policy-service microsoft-github-policy-service bot removed the Needs-Triage Issue need to be triaged label Mar 1, 2025
@mdanish-kh
Copy link
Contributor

Copy link
Contributor

Hello @Xeon-774,

We've identified this as a duplicate of another issue or PR that already exists. This specific instance is being closed in favor of the linked issue. Please add your 👍 to the other issue to raise its priority. Thanks for your contribution!

Template: msftbot/duplicate/closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Feature This is a feature request for the Windows Package Manager client. Resolution-Duplicate Issue is a duplicate
Projects
None yet
Development

No branches or pull requests

2 participants