107 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
Vasily Romanov 7dcf6870f0 Merge pull request #423 from AndreiBerezin/fix-null-string
fix null after MarshalText work
2025-09-15 21:18:01 +03:00
Andrey Berezin 9b7ae67e7e fix null after MarshalText work 2025-06-06 10:19:01 +03:00
dmitrybarsukov 31b2360af5 Return error if trying to marshal +Inf, -Inf or NaN 2025-05-25 23:23:23 +02: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
Artem Utkin 3229627294 Fix null key in map 2024-04-19 11:06:38 +03:00
bulletmys 52ae64103b fix allocs expectations in tests 2021-10-10 19:42:20 +03:00
Alexandr Mayorskiy 87794d0ae8 use easyjson.MarshalerUnmarshaler instead of custom (#299) 2020-07-27 19:20:34 +03:00
Alexandr Mayorskiy 5c65c6fc0e add test with nested marshaler interface 2020-07-14 17:28:28 +03:00
Alexandr Mayorskiy 6ca8fde182 add test with nested marshaler interface 2020-07-14 17:27:06 +03:00
Pavel Parshin 0c9f71dfd2 Fixed skip detection and added correct test 2020-05-10 14:08:06 +03:00
Pavel Parshin e25e66fa75 Added pragma easyjson:skip to exclude structs from generating stage
It allows manually control which struct should be skipped when using option `-all`.
2020-05-10 13:34:43 +03:00
kirillx f0a000e7a8 Previous optimisation in findStringLen has broken unescaping of \\\" sequences (#284)
* tests: don't ignore errors, verify them carefully

* fix unescaping of \\\\\" and such sequences

* tests: add Unmarshal test cases for escaped sequences
2020-04-24 20:26:02 +03: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
Alexandr Mayorskiy 0aa9db2e59 gofmt -s 2020-04-15 00:28:30 +03:00
Alexandr Mayorskiy 6c2d82a4da fix typo & add test for noCopy 2020-04-12 21:35:45 +03:00
Kirill Korotaev 5c9438b0d1 nocopy: add AllocsPerRun test case 2020-04-12 21:22:48 +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
Alexandr Mayorskiy 06957521cc Merge branch 'master' of git://github.com/philpearl/easyjson into philpearl-master 2020-04-12 18:10:39 +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 e0f67b396d Add test cases for non-escaped mode of member names 2020-04-11 19:12:49 +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 2d0de5a8b6 Merge branch 'master' into patch/typespec-docs 2020-03-30 23:27:08 +03:00