Repository navigation
ConvertTo-Json: Serialize BigInteger as a number - #21000
Conversation
Serializes a BigInteger value as a raw JSON number rather than the object's properties which does not contain the BigInteger value.
| } | ||
| else if (obj is BigInteger bi) | ||
| { | ||
| rv = new JRaw(bi.ToString(NumberFormatInfo.InvariantInfo)); |
There was a problem hiding this comment.
Why do we need JRaw?
There was a problem hiding this comment.
So the value isn’t quoted and is a literal numeric value.
There was a problem hiding this comment.
Perhaps we should use string if we agree with #20999 (comment)
There was a problem hiding this comment.
Personally I don't see why we should but I'll leave it up to the WG decision in the end.
If they do decide to quote BigIntegers so then it should only happen if the value is larger than the Javascript precision value. I would have to say I really don’t think it’s a good idea as it complicates the cmdlet even more.
There was a problem hiding this comment.
Turns out it isn't needed we just need to ensure the value is the BigInteger itself and we don't do PowerShell's property enumerator.
|
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) |
|
The WG agrees that the same reasoning in #20999 (comment) applies here |
Patrick Meinecke (SeeminglyScience)
left a comment
There was a problem hiding this comment.
LGTM! Thanks Jordan Borean (@jborean93)!
PR Summary
Serializes a BigInteger value as a raw JSON number rather than the object's properties which does not contain the BigInteger value.
This is technically a breaking change, I went ahead with the PR anyway to see if it was actually possible to do (it is). Waiting for the triage outcome of #20989 (comment) to see if this breaking change is ok or not.
PR Context
Fixes: #20989
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).