Commit fad41aa
Fix JsonValue.Float serialization: append '.0' for whole-number floats
JsonValue.Float(100.0).ToString() previously returned "100" instead of
"100.0", discarding the fact that the value is a float. This causes issues
when downstream consumers expect a JSON float (not an integer).
Root cause: the write path used w.Write(number) for the Float DU case which
calls number.ToString() — and (100.0).ToString() returns "100" in .NET.
Fix: format the float using the "R" round-trip format and, if the result
contains no decimal point or exponent character, append ".0". This matches
the behaviour of JsonValue.Parse("100.0") which correctly serialises as
"100.0" (because decimal 100M with Scale=1 already has the trailing zero).
Closes #1356
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 2566e81 commit fad41aa
2 files changed
Lines changed: 21 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
90 | 96 | | |
91 | 97 | | |
92 | 98 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
293 | 293 | | |
294 | 294 | | |
295 | 295 | | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
296 | 310 | | |
297 | 311 | | |
298 | 312 | | |
| |||
0 commit comments