This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Commit 97af4b4
Fix various issues with System.Json.JsonValue.Save (#26502)
* Fix various issues with System.Json.JsonValue.Save
The `JsonObject` class overrides `JsonValue.Save(Stream)`, but was
implemented incorrectly: it would produce output resembling
`{"key1","value1""key2","value2"}`, instead of the more reasonable
`{"key1": "value1", "key2": "value2"}`. Because `JsonValue` already
contains code that can properly serialize a `JsonObject`, the override
now simply calls the base method.
In addition, it turns out that the `JsonValue.Save(Stream)` method was
also implemented incorrectly. This method would invoke
`JsonValue.Save(TetxtWriter)`, but the `StreamWriter` it created was never
flushed or disposed, so output could go missing. In addition, it would
encode json as utf-8, but would include a BOM, while none of the methods
that override `JsonValue.Save(Stream)` would write a BOM. Both these
issues have been resolved.
The tests have also been modified to test for the new and correct
behavior.
* PR fixes
* Add reference to System.Text.Encoding.Extensions1 parent 3f3e8ec commit 97af4b4
File tree
5 files changed
+25
-32
lines changed- src/System.Json
- src
- System/Json
- tests
5 files changed
+25
-32
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
| 117 | + | |
146 | 118 | | |
147 | 119 | | |
148 | 120 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
| |||
122 | 124 | | |
123 | 125 | | |
124 | 126 | | |
125 | | - | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
126 | 131 | | |
127 | 132 | | |
128 | 133 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
270 | 270 | | |
271 | 271 | | |
272 | 272 | | |
273 | | - | |
| 273 | + | |
274 | 274 | | |
275 | 275 | | |
276 | 276 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
432 | 432 | | |
433 | 433 | | |
434 | 434 | | |
435 | | - | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
436 | 451 | | |
437 | 452 | | |
438 | 453 | | |
| |||
0 commit comments