Skip to content

Releases: Pungyeon/required

v0.6

19 Oct 10:50
5d49f73
Compare
Choose a tag to compare

Fixes bugs for non-existing fields

v0.5

03 Oct 15:19
6f98171
Compare
Choose a tag to compare

Support parsing JSON fields with values, which contain escaped characters. Such as:

{
  "field": "\"value\""
}

Fix a bug which would crash the parser on fields present in JSON, which were not present on the given struct.

v0.4

20 Jan 19:44
5c39b5b
Compare
Choose a tag to compare

Fixes critical bug #25 - and now supports array of maps.

v0.3

20 Jan 19:02
8063d8a
Compare
Choose a tag to compare

Here are the benchmarks from v0.2:

goos: darwin
goarch: amd64
pkg: github.com/Pungyeon/required/pkg/json
BenchmarkStdUnmarshal-8           148515              7747 ns/op            1344 B/op      26 allocs/op
BenchmarkPkgUnmarshal-8            57804             20503 ns/op           17037 B/op     267 allocs/op
PASS
ok      github.com/Pungyeon/required/pkg/json   3.077s

The highlights being ~x3 worse performance than the std library marshaler and more than x10 the memory consumption (and memory allocations). Even though the code was quite nice, the performance was unfortunately horrendous. After the optimisations of this pull request, we see the following results:

goos: darwin
goarch: amd64
pkg: github.com/Pungyeon/required/pkg/json
BenchmarkStdUnmarshal-8           149682              7784 ns/op            1344 B/op      26 allocs/op
BenchmarkPkgUnmarshal-8           155384              7684 ns/op            1512 B/op      34 allocs/op
PASS
ok      github.com/Pungyeon/required/pkg/json   2.941s

These results are much more convincing. I have tried my best to find the last 8 allocations and get rid of them, but it seems that the approach is just different. Either way, it looks like they are quite even in speed, as well as memory consumption. This is great 🎉

There are also a few bugs which have been fixed, such as:

  • Support of custom json marshaling (by extending the std lib json.Unmarshaler interface)....
  • Private fields are ignored (rather than causing a panic)
  • Pointers and Interface types are now parsed in a much nicer manner
  • There is no longer any string -> []byte conversion in the Unmarshalling of the json, making this a lot closer to std library functionality.
  • Support of uint types

Unfortunately, this performance optimisation has made the code quality suffer quite significantly 😬 However, it's still more understandable than the code in the std library 😅 So I'll let it pass for now.

v0.2

06 Sep 19:57
Compare
Choose a tag to compare

Change Log:

  • Major bug fix in how field validation is performed.
  • Public constructors on all supported types
  • No longer using sql.Database Null types, but using own Nullable type
  • Small Refactor
  • Update to article

v0.1

04 Sep 09:36
Compare
Choose a tag to compare
spell check