140 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
Andrey Berezin 9b7ae67e7e fix null after MarshalText work 2025-06-06 10:19:01 +03:00
Neal Patel baefa5cf6e Fix decoding null values on non-pointer fields 2025-01-09 11:27:28 -08:00
Neal Patel 529b1f6f7e Fix unmarshal null to existing value 2024-12-18 21:43:31 -08:00
Vasily Romanov 5e854fb809 Merge pull request #388 from testwill/string
chore: use ret.String() instead of string(ret.Bytes())
2024-12-14 21:24:10 +03:00
Artem Utkin 3229627294 Fix null key in map 2024-04-19 11:06:38 +03:00
guoguangwu 37cdbe9d67 chore: use ret.String() instead of string(ret.Bytes()) 2023-06-29 15:18:48 +08:00
Denis Zinovyev e33cca903c fix too many arguments in call to MarshalJSON 2021-06-15 21:44:37 +03:00
Zik 853c4976cc Remove spurious print (#300) 2020-08-10 12:17:50 +03:00
i.anferov 2cb8c451eb Duplicated json values on marshalind interfaces implementing easyjson.Marshaler 2020-07-14 17:36:35 +05:00
Alexandr Mayorskiy 3b0c433891 Revert "Don't pass field tags into nested types"
This reverts commit 9e9dfede4e.
2020-04-15 00:45:56 +03:00
Kirill Korotaev f27c653a50 don't allow intern/nocopy tags at the same time 2020-04-12 21:22:21 +03:00
Kirill Korotaev 244a66fa8f Add "nocopy" json tag to return unsafe string reference
When large amounts of data are unmarshaled for immediate non long live use than
copying of strings from original buffer can be avoided and instead a
reference to the original buffer returned in the field value.

Note, if the value requires unescaping, than it will be processed as
normally done with copying.

Signed-off-by: Kirill Korotaev <kirillx@gmail.com>
2020-04-12 20:48:07 +03:00
GoWebProd 0d5e07263b Merge pull request #202 from makarchuk/better-interfaces-support
Add checks for json/easyjson marshaler/unmarshaler interfaces
2020-04-12 19:26:52 +03:00
Alexandr Mayorskiy 6ea07b37bb Merge branch 'cafxx-intern' of git://github.com/CAFxX/easyjson into CAFxX-cafxx-intern 2020-04-12 17:56:50 +03:00
GoWebProd 67202f7869 Merge pull request #271 from creker/NestedOmitempty
Don't pass fields tags into nested types
2020-04-12 17:32:32 +03:00
Kirill Korotaev 33d35f870a unescaping: should process string numbers in unescaped member names mode
There was a small glitch:
numbers as strings where not unescaped in -disable_members_unescape
mode, though this mode was implied to affect field names only.
2020-04-11 20:20:50 +03:00
Kirill Korotaev 9a01c9afdb Add new -disable_members_unescape option to avoid unescaping of member names, ints, ...
Improves performance for about 15% on BenchmarkEJ_Unmarshal_M-8
2020-04-11 19:11:39 +03:00
Carlo Alberto Ferraris c124e4243f Implement optional string interning
Fixes https://github.com/mailru/easyjson/issues/191
2020-04-08 08:08:39 +09:00
GoWebProd 5eb0584d0e fix generator 2020-03-30 23:49:40 +03:00
GoWebProd 7db1436caf Merge branch 'master' into master 2020-03-30 23:46:53 +03:00
GoWebProd e790aae53f Merge pull request #204 from hhh0pE/unnamed_embedded_field
improved gen getStructFields: for anonymous field that is not a struct.
2020-03-30 23:38:48 +03:00
GoWebProd 8c3dabd22a Merge pull request #245 from Bogdan-D/bugfix/zero_divide
fix panic divide by zero
2020-03-30 23:12:59 +03:00
creker 9e9dfede4e Don't pass field tags into nested types 2020-03-03 16:41:45 +03:00
Anton Sulaev e17df41dc6 add interfaces to provide marshal/unmarshal logic for unknown fields in struct 2020-02-17 19:52:40 +03:00