1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
|
# v0.3.8 (TBD)
Theme: Fixes from fuzzing (part 2/?)
User-facing changes:
- Feature: There is a new `DecodeString` helper function.
- Change: Decoder: No longer bails when a type error
(`DecodeTypeError`) is encountered. The part of the output value
with the type error is either unmodified (if already existing) or
set to nil/zero (if not already existing), and decoding
continues. If no later fatal error (syntax, I/O) is encountered,
then the first type error encountered is returned. This is
consistent with the behavior of `encoding/json`.
- Change: Several error strings have been reworded to match
`encoding/json`.
- Bugfix: Decoder: If there is a syntax error in a byte that
invalid UTF-8, include that byte value in the error message
rather than including the U+FFFD Unicode replacement character.
# v0.3.7 (2023-02-20)
Theme: Fixes from fuzzing (part 1?)
User-facing changes:
- General Changes:
+ Change: ReEncoder: No longer compact floating-point numbers by
default, add a `CompactFloats` ReEncoderConfig option to
control this.
+ Bugfix: Encoder, ReEncoder: Now correctly trims unnecessary
the trailing '0's from the fraction-part when compacting
numbers.
+ Bugfix: Decoder: Decoding `json.Unmarshaler` or
`lowmemjson.Decodable` as a top-level value no longer needs to
read past the closing `"`/`]`/`}`; this can be significant
when reading streaming input, as that next read may block.
- Compatibility bugfixes:
+ compat/json.Valid: No longer considers truncated JSON
documents to be valid.
+ compat/json.Compact, compat/json.Indent: Don't write to the
destination buffer if there is a syntax error.
+ compat/json.Compact, compat/json.Indent: No longer compact
floating-point numbers; as `encoding/json` doesn't.
+ compat/json.HTMLEscape: Just look for problematic UTF-8 runes,
don't actually parse as JSON. This is consistent with the
function's lack of an `error` return value, and with the
behavior of `encoding/json`.
+ compat/json.Indent: Preserve trailing whitespace, same as
`encoding/json`.
+ compat/json.Decoder: No longer transforms "unexpected EOF"
errors to "unexpected end of JSON input". This makes it
different than `compat/json.Unmarshal`, but the same as
`encoding/json`.
+ compat/json.Decoder, compat/json.Unmarshal: No longer mutate
the target value at all if there is a syntax error in the
input.
- Unicode:
+ Feature: Encoder, ReEncoder: Add an `InvalidUTF8`
ReEncoderConfig option and `BackslashEscapeRawByte`
BackslashEscapeMode to allow emitted strings to contain
invalid UTF-8.
+ Feature: ReEncoder: No longer unconditionally normalizes
`\uXXXX` hex characters to lower-case; now this is controlled
by the `BackslashEscaper` (and the default is now to leave the
capitalization alone).
+ Change: EscapeDefault, EscapeDefaultNonHTMLSafe: No longer
force long Unicode `\uXXXX` sequences for the U+FFFD Unicode
replacement character.
+ Change: Encoder: Unless overridden by the BackslashEscaper,
now by default uses `\uXXXX` sequences when emitting the
U+FFFD Unicode replacement character in place of invalid
UTF-8.
+ Bugfix: Encoder, ReEncoder: Fix an issue with decoding UTF-8
that when a codepoint straddles a write boundary it is
interpreted as a sequence of U+FFFD runes.
+ Bugfix: compat/json.Valid: Do not consider JSON containing
invalid UTF-8 to be valid (this is different than
`encoding/json` at the time of this writing; but I consider
that to be a bug in `encoding/json`; [go#58517][]).
+ Bugfix: compat/json.Compact, compat/json.Indent: Don't munge
invalid UTF-8 in strings; as `encoding/json` doesn't.
[go#58517]: https://github.com/golang/go/issues/58517
# v0.3.6 (2023-02-16)
Theme: Architectural improvements
User-facing changes:
- Change: ReEncoder: The ReEncoderConfig struct member is no longer
public.
- Change: ReEncoder: `WriteRune` may now be called even if there is
a partial UTF-8 codepoint from a `Write` or `WriteString` call,
but now simply returns the width of the rune, rather than the
number of bytes actually written.
- Feature: `Number` and `RawMessage` type aliases are now
available, so that a user of lowmemjson's native APIs does not
need to import `encoding/json` or compat/json in order to use
them.
- Bugfix: Encoder, ReEncoder: If there was an error writing to the
output stream, it may have returned a `*ReEncodeSyntaxError` even
though it's not a syntax issue, or may have returned the
underlying error without wrapping it. If there is an error
writing to the output, Encoder and ReEncoder now return
`*EncodeWriteError` and `*ReEncodeWriteError` respectively.
# v0.3.5 (2023-02-10)
Theme: Compatibility bugfixes
User-facing changes:
- Decoder: Fixes a bug where if an EOF is encountered, the reader
is appended to, then another Decode is attempted, that EOF
poisons future Decodes. This is something that `encoding/json`
supports.
- Encoder: Fixes a bug where if an encode error is encountered, all
future Encode calls will fail. Reusing an Encoder is something
that `encoding/json` supports.
- compat/json.Encoder: Now buffers the output, to avoid partial
writes if an encode error is encountered. This matches the
behavior of `encoding/json`. For memory consumption reasons, the
native lowmemjson Encoder still does not buffer.
# v0.3.4 (2023-02-05)
Theme: Fix compilation with Go 1.20
lowmemjson uses git.lukeshu.com/go/typedsync.CacheMap (since
lowmemjson v0.3.1), which when compiled with Go 1.20 makes use of Go
1.20 language features. However, because lowmemjson's `go.mod` said
`go 1.18`, those language features are disabled and compilation
fails (see [go#58342][]). To work around this, lowmemjson's
`go.mod` now says `go 1.20`. Despite this, lowmemjson still works
fine with Go 1.18.
[go#58342]: https://github.com/golang/go/issues/58342
# v0.3.3 (2023-02-04)
Theme: Bugfix
User-facing changes:
- ReEncoder: Fixes a regression in v0.3.1 where it erroneously
enters compact mode when CompactIfUnder is set and write barriers
are in use.
- ReEncoder: Fixes a regression in v0.3.1 where it sometimes emits
extra (but syntactically valid) newlines when write barriers are
in use.
# v0.3.2 (2023-02-03)
Theme: Bugfix
User-facing changes:
- ReEncoder: Fixes a regression in v0.3.1 where it sometimes emits
extra (but syntactically valid) newlines.
# v0.3.1 (2023-01-31)
Theme: Performance
This release does a bunch of performance tuning and optimizations,
with no user-visible changes other than memory consumption and CPU
time. Based on benchmarks with a real-world use-case, it is now
roughly an order of magnitude faster, with much lower memory
consumption (the big-O of memory consumption was always pretty low,
but there were some big constant factors before).
# v0.3.0 (2023-01-30)
Theme: Breaking changes
This release makes a breaking change to the way *ReEncoder works.
This change both better fits what's convenient to use, and enables
making future performance improvements.
Breaking changes:
- ReEncoder: Instead of instantiating a `*ReEncoder` with
```go
reenc := &lowmemjson.ReEncoder{Out: w, settings}
```
it is now instantiated with
```go
reenc := lowmemjson.NewReEncoder(w, lowmemjson.ReEncoderConfig{settings})
```
# v0.2.1 (2023-01-30)
Theme: Code quality
This release improves code quality; getting various linters to pass,
adding tests (and a few bug-fixes), refactoring things to be
clearer, fixing some mistakes in the documentation.
User-facing changes:
- Encoder: `*EncodeMethodError` is now also used when a method
produces invalid JSON.
- Decoder: The offset in `*DecodeTypeError`s now correctly point
the start of the value, rather than somewhere in the middle of
it.
# v0.2.0 (2023-01-26)
Theme: Add documentation
This release doesn't make any major changes, and is just adding
documentation. I have removed a few minor things that I didn't want
to write documentation for.
Breaking changes:
- Drop the following shorthand functions:
+ `func Decode(r io.RuneScanner, ptr any) error { return NewDecoder(r).Decode(ptr) }`
+ `func DecodeThenEOF(r io.RuneScanner, ptr any) error { return NewDecoder(r).DecodeThenEOF(ptr) }`
+ `func Encode(w io.Writer, obj any) (err error) { return NewEncoder(w).Encode(obj) }`
- Drop `const Tab = "\t"`.
# v0.1.0 (2022-09-19)
Theme: Initial release
|