ConvertTo-Json: Serialize BigInteger as a number (#21000)

This commit is contained in:
Jordan Borean
2024-02-27 14:52:58 -08:00
committed by GitHub
parent 338d1dcfa1
commit fcf4953c3b
2 changed files with 13 additions and 1 deletions
@@ -146,4 +146,14 @@ Describe 'ConvertTo-Json' -tags "CI" {
$t = Add-Member -InputObject $text -MemberType NoteProperty -Name text -Value $text -PassThru
$t | ConvertTo-Json -Compress | Should -BeExactly "`"$text`""
}
It 'Should serialize BigInteger values' {
$obj = [Ordered]@{
Positive = 18446744073709551615n
Negative = -18446744073709551615n
}
$actual = ConvertTo-Json -Compress -InputObject $obj
$actual | Should -Be '{"Positive":18446744073709551615,"Negative":-18446744073709551615}'
}
}