1
0
mirror of https://github.com/json-iterator/go.git synced 2024-11-27 08:30:57 +02:00
Commit Graph

756 Commits

Author SHA1 Message Date
Tao Wen
3c298d8a76 Merge pull request #172 from olegshaldybin/more-stdlib-compat
Improve stdlib compatibility
2017-09-17 03:05:36 -05:00
Oleg Shaldybin
9f6e5962a9 Improve stdlib compatibility
1. Null values for primitive types no longer clear the original value in
the destination object.

2. Dereference multiple levels of pointers in the destination interface{}
type before unmarshaling into it. This is needed to match stdlib
behavior when working with nested interface{} fields. If the destination
object is a pointer to interface{} then the incoming nil value should
nil out the destination object but keep the reference to that nil value
on its parent object. However if the destination object is an
interface{} value it should set the reference to nil but keep the
original object intact.

3. Correctly handle typed nil decode destinations.
2017-09-16 16:57:51 -07:00
Tao Wen
c463aa12c4 Merge pull request #173 from toffaletti/more-nil-interface-fixes
More nil interface fixes
2017-09-16 18:36:43 -05:00
Jason Toffaletti
b5d2607a6d replace should.Equal(nil, err) with should.NoError(err) 2017-09-16 16:30:04 -07:00
Jason Toffaletti
48cc4d965a improve test 2017-09-16 16:27:32 -07:00
Jason Toffaletti
c59c42fda0 fix decoding of nil non-empty interface 2017-09-16 16:24:55 -07:00
Jason Toffaletti
8324374402 add tests for decoding nil interfaces 2017-09-16 16:24:27 -07:00
Jason Toffaletti
2017f3866b fix encoding of nil marshaler interface 2017-09-16 16:08:32 -07:00
Jason Toffaletti
ddc5af4512 fix encoding of nil non-empty interface 2017-09-16 16:04:36 -07:00
Jason Toffaletti
2f7e5c8dd7 add failing tests for nil non-empty interfaces 2017-09-16 16:00:48 -07:00
Tao Wen
92772579dd Merge pull request #170 from olegshaldybin/marshal-enum-pointer
Fix custom marshaler for enum types
2017-09-15 09:08:45 -05:00
Oleg Shaldybin
ae57d167e8 Fix custom marshaler for enum types
When MarshalJSON was defined on a pointer receiver custom enum type
marshaling/unmarshaling was panicing since the underlying primitive type
was treated as a pointer.

Since method set for pointer receivers includes value receiver methods
we don't really need optionalEncoder and can just use marshalEncoder
directly.
2017-09-14 23:26:12 -07:00
Tao Wen
eef35e549b Merge pull request #169 from toffaletti/fix-nil-interface
Fix handling of nil empty interface
2017-09-15 00:45:11 -05:00
Jason Toffaletti
005d86dc44 fix handling of nil empty interface 2017-09-14 21:32:42 -07:00
Jason Toffaletti
e658f6597a add failing test for handling of nil interface with omitempty 2017-09-14 20:44:42 -07:00
Tao Wen
f8eb43eda3 Merge pull request #168 from olegshaldybin/null-booleans
Allow null booleans
2017-09-14 20:58:31 -05:00
Oleg Shaldybin
18a241d40b Allow null booleans
Make sure we do the same thing as stdlib with null booleans by not
touching the original value and discarding the null.

Another somewhat related change is nulling out null interface values in
the original structure. This also matches stdlib behavior.
2017-09-14 16:47:35 -07:00
Tao Wen
0fdf883ac0 Merge pull request #167 from olegshaldybin/shorter-sleep
Shorter sleep while waiting for encoder/decoder
2017-09-14 18:23:29 -05:00
Oleg Shaldybin
34fbec74ad Shorter sleep while waiting for encoder/decoder
If the client is using the same jsoniter config with multiple goroutines
it's very likely that few initial operations will encounter a placeholder
encoder/decoder while the real one is being created by another
goroutine. Having a full second sleep seems too conservative, since
encoder/decoder will be created in a very short time. This is very easy
to reproduce in any real environment with a few concurrent requests of
the same type. A few initial requests will have 1s+ response time.

Changing to 10ms should smooth out marshal/unmarshal times for these
initial concurrent requests.
2017-09-14 12:37:47 -07:00
Tao Wen
90574c5ca3 #166 support ValidateJsonRawMessage in ConfigCompatibleWithStandardLibrary 2017-09-14 23:54:40 +08:00
Tao Wen
6a4ba7bfa9 Merge branch 'master' of https://github.com/json-iterator/go 2017-09-09 08:46:07 +08:00
Tao Wen
0828e559d0 #164 support interface{} with ptr 2017-09-09 08:45:57 +08:00
Tao Wen
2c67d0f68a Merge pull request #163 from dvrkps/patch-2
travis: add 1.x to go versions
2017-09-07 11:25:07 -05:00
Davor Kapsa
f29a0391bc travis: add 1.x to go versions 2017-09-07 17:12:42 +02:00
Tao Wen
374e68a144 Merge pull request #162 from cch123/fix-bool-to-number
fix fuzzy decoder from bool value to number
2017-09-06 00:19:18 -05:00
Xargin
b134d86290 optimize code 2017-09-06 13:18:05 +08:00
Xargin
bc3221879d fix fuzzy decoder from bool value to number 2017-09-06 12:31:56 +08:00
Tao Wen
8c7fc7584a #159 fix fuzzy decoder, the newIter assigned io.EOF error to original iterator, which stopped further processing 2017-09-06 00:31:25 +08:00
Tao Wen
db32ee8c2d #157 number can be null 2017-09-05 13:00:03 +08:00
Tao Wen
d80309af3b #156 invoke Marshaler defined on pointer types 2017-09-01 15:44:12 +08:00
Tao Wen
36b14963da #153 fix invalid utf8 using same implementation as the standard library 2017-08-29 23:58:51 +08:00
Tao Wen
f706335302 #153 fix critical bug: infinite loop when write string is invalid utf8 2017-08-29 23:39:43 +08:00
Tao Wen
2dc0031b26 #152 gofmt 2017-08-25 12:53:23 +08:00
Tao Wen
cdbd2ed810 #145 interface {} customizatoin is recursive 2017-08-22 10:39:01 +08:00
Tao Wen
39e9d67807 Merge branch 'master' of https://github.com/json-iterator/go 2017-08-22 00:12:18 +08:00
Tao Wen
2066b01acb #146 support config TagKey 2017-08-22 00:12:09 +08:00
Tao Wen
ac3b3cd160 test []interface{} 2017-08-21 22:43:51 +08:00
Tao Wen
887789156a Merge pull request #147 from thockin/output_tests
Add tests for int64
2017-08-11 12:55:48 +08:00
Tim Hockin
7df5a67d0d Add tests for int64 2017-08-10 20:58:49 -07:00
Tao Wen
9c358632dc #144 make []byte support Unmarshaler&Marshaler 2017-08-09 13:59:40 +08:00
Tao Wen
1cfa233923 #143 make jsoniter.Number same meaning as json.Number, however UseNumber still returns json.Number. 1.9 alias support should be added later 2017-08-05 07:22:53 +08:00
Tao Wen
d249b05a85 rename ValueType, to avoid collision with json.Number 2017-08-05 07:10:15 +08:00
Tao Wen
abbd16da6c #140 blind fix 2017-08-02 09:20:43 +08:00
Tao Wen
b67201557a avoid gc issue 2017-08-01 08:34:38 +08:00
Tao Wen
5124683f24 #140 try fix: maybe memory collected before assigned to existing object graph 2017-07-31 23:24:58 +08:00
Tao Wen
4892de725b add ad 2017-07-31 21:49:02 +08:00
Tao Wen
34a2174be3 #142 decode struct field should be case insensitiveyet another fix 2017-07-31 21:48:22 +08:00
Tao Wen
24ecaff2a1 #142 decode struct field should be case insensitive, the bug only happen for struct with more than 10 fields 2017-07-31 20:50:07 +08:00
Tao Wen
c15b4d116c #139 unmarshal non base64 into []byte 2017-07-19 12:04:22 +08:00
Tao Wen
12cd299fa8 add benchmark for Skip() 2017-07-19 00:22:41 +08:00