Skip to content

ConvertTo-Json: implement "streaming" mode #26533

Description

Summary of the new feature / enhancement

Currently, the ConvertTo-Json cmdlet assembles all input objects into an in-memory List, then converts that to one Json string for output. This can be inefficient if there are many input objects.

Enhancing ConvertTo-Json to (optionally) convert each input object to a complete Json string and output
as it is processed offers these benefits:

  • reduced memory usage
  • substantially improved throughput when the output stream is being processed by a separate thread
    or process.

Proposed technical implementation details (optional)

Add an AsStream parameter to the cmdlet and modify the code to convert and output each object individually.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugNeeds-TriageThe issue is new and needs to be triaged by a work group.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdletsgeneral cmdlet issuesWG-ReviewedA Working Group has reviewed this and made a recommendation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions