Commit a7526bb
committed
encoding/json: marshal maps using reflect.Value.MapRange
Map serialization using reflect.Value.MapIndex cannot retrieve
map keys that contain a NaN, resulting in a panic.
Switch the implementation to use the reflect.Value.MapRange method
instead, which iterates over all map entries regardless of whether
they are directly retrievable.
Note that according to RFC 8259, section 4, a JSON object should
have unique names, but does not forbid the occurrence of duplicate names.
Fixes golang#43207
Change-Id: If4bc55229b1f64b8ca4b0fed37549725efdace39
Reviewed-on: https://go-review.googlesource.com/c/go/+/278632
Trust: Meng Zhuo <mzh@golangcn.org>
Trust: Joe Tsai <thebrokentoaster@gmail.com>
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Meng Zhuo <mzh@golangcn.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>1 parent 96a96a9 commit a7526bb
2 files changed
+40
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
794 | 794 | | |
795 | 795 | | |
796 | 796 | | |
797 | | - | |
798 | | - | |
799 | | - | |
800 | | - | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
801 | 802 | | |
802 | 803 | | |
803 | 804 | | |
804 | 805 | | |
805 | | - | |
| 806 | + | |
806 | 807 | | |
807 | 808 | | |
808 | 809 | | |
809 | 810 | | |
810 | 811 | | |
811 | | - | |
| 812 | + | |
812 | 813 | | |
813 | | - | |
| 814 | + | |
814 | 815 | | |
815 | 816 | | |
816 | 817 | | |
| |||
997 | 998 | | |
998 | 999 | | |
999 | 1000 | | |
1000 | | - | |
1001 | | - | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
1002 | 1004 | | |
1003 | 1005 | | |
1004 | 1006 | | |
1005 | | - | |
1006 | | - | |
| 1007 | + | |
| 1008 | + | |
1007 | 1009 | | |
1008 | 1010 | | |
1009 | | - | |
1010 | | - | |
| 1011 | + | |
| 1012 | + | |
1011 | 1013 | | |
1012 | 1014 | | |
1013 | 1015 | | |
1014 | | - | |
| 1016 | + | |
1015 | 1017 | | |
1016 | 1018 | | |
1017 | | - | |
| 1019 | + | |
1018 | 1020 | | |
1019 | | - | |
| 1021 | + | |
1020 | 1022 | | |
1021 | 1023 | | |
1022 | | - | |
| 1024 | + | |
1023 | 1025 | | |
1024 | 1026 | | |
1025 | 1027 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
248 | 264 | | |
249 | 265 | | |
250 | 266 | | |
| |||
854 | 870 | | |
855 | 871 | | |
856 | 872 | | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
857 | 877 | | |
858 | 878 | | |
859 | 879 | | |
| |||
872 | 892 | | |
873 | 893 | | |
874 | 894 | | |
| 895 | + | |
875 | 896 | | |
876 | 897 | | |
877 | 898 | | |
| |||
0 commit comments