Repository navigation
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ConvertTo-Json: add parameter AsStream, to implement "streaming" mode #25597
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
base: master
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
ConvertTo-Json: add parameter AsStream, to implement "streaming" mode #25597
Changes from all commits
24f7645ee5749a59914cc9eacb468a9b4ceFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't this still be used with
-AsStream, e.g.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could. Alternatively, the -AsArray -AsStream combo could output a single Json array, but output as multiple strings such that the data would not all be buffered in memory.
I'm undecided which would be best.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure a new parameter set is actually needed here, the switch itself is what is signalling whether to stream or not. I don't think that
-AsArrayand-AsStreamare mutually exclusive as well as you can stream JSON arrays.One thing to keep in mind about this pattern, if someone was to set the switch to false it will still go through the parameter set locking you into whatever parameters are exposed in there.
If
-AsArraywas mutually exclusive (just a hypothetical) then doing"foo" | ConvertTo-Json -AsArray -AsStream:$AsStreamwould fail if$AsStreamwas false. You would have to conditionally add the switch which is not ideal.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used the parameter sets to disallow the -AsArray -AsStream combo.
That way it will not be a breaking change when it is decided to make the combo do something.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.