-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Remove pre-parse for array-based JSON #15684
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
Conversation
|
Have we direct test for the scenario? |
|
I manually tested this but it looks like a test like what was added earlier and then removed would work? Thoughts? |
I added a test for this scenario |
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
|
I believe that this is ready to merge. |
|
I think this is ready if any of the pending reviewers have any questions |
|
This PR has Quantification details
Why proper sizing of changes matters
Optimal pull request sizes drive a better predictable PR flow as they strike a
What can I do to optimize my changes
How to interpret the change counts in git diff output
Was this comment helpful? 👍 :ok_hand: :thumbsdown: (Email) |
|
Reopened PR to reset hanging PR checks. |
|
/azp run |
|
Azure Pipelines successfully started running 5 pipeline(s). |
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
|
/rebase |
|
Started rebase: https://github.com/PowerShell/PowerShell/actions/runs/2734744349
|
|
The pre-parsing was previously removed by #8346, but then a regression was found because a feature-level test failed: #8346 (comment), and hence the change was reverted (#8375). I have verified that the previously failing feature-level test passes with changes in this PR. So, it looks to me we are safe to merge this PR. PowerShell/test/powershell/Modules/Microsoft.PowerShell.Utility/Json.Tests.ps1 Lines 1698 to 1711 in 3d4e294
|
|
Great! Thank you! |
|
Thank you, @strawgate, for the contribution! |
|
🎉 Handy links: |

PR Summary
Removes a previously-needed check from the convertfrom-json cmdlet. It appears a pre-parsing step was added for json whose root element was an array -- because of some issues with how Newtonsoft handled issues with Arrays in deserializeObject JamesNK/Newtonsoft.Json#1930
Upon further testing this bug is no longer present in Newtonsoft.Json and this preparsing can be removed. This was previously attempted and then rolled back because newtonsoft.json failed when deserializing a
[. I have no idea why we needed to double parse this to check if the contents were[but the tests are passing and the cases previously listed as causing issues are now working.PR Context
It makes ConvertFrom-Json and Invoke-RestMethod ~50% faster. It does not reduce memory usage because the pre-parsing was immediately tossed out after it occurred.
Benchmark for parsing a 100MB JSON blob whose root element is an array.
Master:
Run Built-in Cmdlet: Hashtable
Run Built-in Cmdlet: PSCustomObject
ThisPR:
Run Built-in Cmdlet: Hashtable
Run Built-in Cmdlet: PSCustomObject
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.(which runs in a different PS Host).