44 Commits

Author SHA1 Message Date
Nicolas S. Dade 89250dbfdd Support for json:",omitzero" tag (#429)
* add support for the json:",omitzero" tag

omitzero was added to the go stdlib encoder/json in go 1.24

* add case which omitempty missed: uintptr is encodable in json

and does accept omitempty in the go stdlib encoder/json.

* add omitzero test cases for pointer-to-"" and pointer-to-{}

(both should marshal to something in order to match stdlib json, and
they do)

* fix and add tests for the case when omitzero is combined with omitempty

Without a special case the generated code can look like

   if v != nil && v != nil {
or
   if v != "" && v != "" {

and that gets flagged by go vet (go 1.25.5)
2026-03-14 17:51:56 +03:00
Artem Utkin 3229627294 Fix null key in map 2024-04-19 11:06:38 +03:00
Alexandr Mayorskiy 0aa9db2e59 gofmt -s 2020-04-15 00:28:30 +03:00
creker 9e9dfede4e Don't pass field tags into nested types 2020-03-03 16:41:45 +03:00
Aravind Gopalan d6768890ec Allow empty maps for required map fields (issue #256)
As reported in issue #256, currently, an empty map is unmarshalled into nil by easyjson
If a field is marked "required" or "!omitempty", then the empty map is a valid input and
we should unmarshal it into an empty map.

Similar logic for marshalling.

This change is to fix the behavior
2019-11-21 18:03:16 -08:00
IncSW 09f3bc3a8f fix marshaling for uint8 custom types 2018-04-27 01:46:49 +03:00
Vasily Romanov 517203d186 Merge pull request #158 from regeda/invalid_indirect_of_pointer_on_array
fix invalid indirect of a pointer on a array
2018-03-20 16:17:58 +03:00
Anthony Regeda 95baeb8ee7 invalid_indirect_of_pointer_on_array fix invalid indirect of a pointer on a array 2017-12-19 13:06:15 +03:00
Levi Gross b5dedd1b9e We now include and pass tests
Signed-off-by: Levi Gross <levi@levigross.com>
2017-11-26 18:55:54 -05:00
Levi Gross 56cec8d348 Ensure decoder is set as well
Signed-off-by: Levi Gross <levi@levigross.com>
2017-11-26 18:47:04 -05:00
Levi Gross 4f31de8934 Add float string functions when requested
Signed-off-by: Levi Gross <levi@levigross.com>
2017-11-26 18:36:47 -05:00
Kwisatz a2a98adabc fix problem with installation on 32-bit system 2017-11-04 22:01:21 +03:00
Anton 8b2f92253d fix problem with installation on 32-bit system 2017-11-04 21:24:12 +03:00
Chuntao Lu 86f5f60c4e Add tests for integer keyed maps 2017-10-19 20:28:37 -07:00
Vladimir Varankin 1a411a8244 proper encoding.TextMarshaler interfaces handling
Currently easyjson doesn't handle [encoding.TextMarshaler][1] interfaces.
This leads to a situation where types like [net.IP][2] are handled
as Base64Bytes.

[1]: https://godoc.org/encoding#TextMarshaler
[2]: https://godoc.org/net#IP
2017-03-06 21:23:53 +03:00
dd 5e011ce0b0 Merge branch 'master' of github.com:mailru/easyjson
# Conflicts:
#	tests/basic_test.go
#	tests/data.go
2016-11-07 11:32:29 +03:00
Victor Starodub 159cdb893c Add encoder options to serialize 'nil' maps/slices as empty object/array. 2016-11-03 17:18:12 +03:00
dd 532bbefda8 Fix unmarshaling struct with interface field which is a pointer to a struct (part 2: test) 2016-10-14 11:46:51 +03:00
Victor Starodub 2ea6ed0ea8 Allow marshalling "named" maps. 2016-10-07 15:52:17 +03:00
Nicolas S. Dade 1f84fdd339 array unmarshal under/overflow unit tests
make sure the behavior matches that of encoding/json
2016-09-23 21:10:22 -07:00
Nicolas S. Dade bc1638cf78 Add support for array types
Arrays are useful to decode into to keep the allocations down
and thus the gc pressure low.

The code allows the json to contain truncated arrays without
raising an error, same as standard encoding/json. However excess
elements in the json is an error.
2016-09-22 01:51:36 -07:00
jz b0ee67a33d Follow encoding/json spec when dealing with slices
- nil slices are encoded as JSON nulls
- empty slices are encoded as empty JSON arrays
- byte slices are encoded as base 64 encoded JSON strings

Demo: https://play.golang.org/p/Z_YE5PHS3g
2016-08-22 13:17:43 -07:00
Aleksandr Petrukhin 7f82bd347f Added test-case for slice marshalling 2016-07-18 16:21:03 +03:00
Aleksandr Petrukhin 8b05604eb9 Added tests for slice in response 2016-07-15 18:21:20 +03:00
Vasily Romanov 45c84278be correct encode broken utf 2016-07-14 13:47:41 +03:00