26 Commits
Author SHA1 Message Date
Vasily RomanovandGitHub 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
Artem Utkin 3229627294 Fix null key in map 2024-04-19 11:06:38 +03:00
Carlo Alberto Ferraris 03e03cfa69 Do not copy escape tables 2020-02-29 16:28:16 +09:00
Alexandr Mayorskiy e6347e1e0b optimize writer 2019-10-08 22:47:07 +03: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
Michael MonashevandGitHub 00e42d3ff0 avoid memory allocation while []byte encoding 2017-11-05 22:09:23 +03:00
Chuntao Lu 06d7c00bd4 Support integer type as map key 2017-10-19 19:41:26 -07:00
Vladimir Varankin 29907909d5 escape TextMarshaler's results 2017-03-07 12:49:45 +03: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
Sergey KamardinandGitHub 7a67b2a713 Merge pull request #77 from erikdubbelboer/readcloser
Add ReadCloser method to jwriter and buffer
2017-02-17 15:26:27 +03:00
Erik Dubbelboer ce0e78724b Add ReadCloser method to jwriter and buffer
When marshalling something as body for a http.Request we can only use
BuildBytes() which always allocates a buffer for our whole body. This
pull request adds a ReadCloser() method which returns an io.ReadCloser
that can be passed as body into http.NewRequest. This ReadCloser will
read from the existing buffs and putBuf them when they are not needed
anymore.
2017-02-17 16:38:15 +08:00
Vasily RomanovandGitHub 26c018fb9c Merge pull request #78 from erikdubbelboer/reusebuildbyte
Allow reusing of buffer in BuildBytes()
2017-02-16 16:32:50 +03:00
Erik Dubbelboer daae07b7e6 Add NoEscapeHTML to jwriter.Writer
This option is similar to json.Encoder.SetEscapeHTML. The default
behavior of false is to escape &, <, and > to \u0026, \u003c, and
\u003e. Setting this to true will not escape these.
2017-01-16 06:23:14 +00:00
Erik Dubbelboer bb6375f4c8 Allow reusing of buffer in BuildBytes()
This adds an optional parameter to BuildBytes() which allows for reusing
of a byte buffer. Because it's an optional parameter it will not break
backwards compatibility.

This allows people to use a sync.Pool for the buffers used by
BuildBytes() to reduce garbage generation.
2016-11-29 08:59:17 +00:00
Victor Starodub 159cdb893c Add encoder options to serialize 'nil' maps/slices as empty object/array. 2016-11-03 17:18:12 +03: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
Victor Starodub db9160d577 Faster string marshalling. 2016-08-15 00:27:55 +03:00
Vasily Romanov 45c84278be correct encode broken utf 2016-07-14 13:47:41 +03:00
Vasily Romanov ab247a4b51 escape lt, gt 2016-06-14 17:22:41 +03:00
Victor Starodub af01f9e8dc Support json:"string" field tag. 2016-04-18 15:40:08 +03:00
Victor Starodub acb943cc36 Minor readability improvement. 2016-04-14 13:05:24 +03:00
Victor Starodub f6687fef12 Marshalling null instead of empty slice in Raw(). 2016-04-14 13:03:15 +03:00
Andrew Po 02a08ab4b1 fix for Writer.String 2016-04-04 15:58:13 +03:00