Commit 962fde5
committed
Fix: Double-quoted types when encoded to JSON
When encoding map keys to JSON it will give priority to the
`encoding.TextMarshaler` implementation, automatically adding quotes to the
encoded value. If the encoding already add the quotes it will end up with a
double-quoted JSON property that may cause issues in the decoding phase.
From https://pkg.go.dev/encoding/json#Marshal:
> The map's key type must either be a string, an integer type, or implement
> encoding.TextMarshaler.
>
> * keys of any string type are used directly
> * keys that implement encoding.TextMarshaler are marshaled
> * integer keys are converted to strings1 parent bd44192 commit 962fde5
1 file changed
+21
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
85 | 86 | | |
86 | 87 | | |
87 | 88 | | |
88 | | - | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
89 | 99 | | |
90 | 100 | | |
91 | 101 | | |
| |||
124 | 134 | | |
125 | 135 | | |
126 | 136 | | |
127 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
128 | 147 | | |
129 | 148 | | |
130 | 149 | | |
| |||
0 commit comments