1
0
mirror of https://github.com/json-iterator/go.git synced 2024-12-09 08:55:35 +02:00
Commit Graph

577 Commits

Author SHA1 Message Date
Tao Wen
f1258b01aa fix #191 do not always assume the object field is simple string 2017-10-31 22:38:41 +08:00
Tao Wen
fbd210edfc Merge pull request #189 from ggaaooppeenngg/compatible-with-map
Fix standard compatiblility
2017-10-26 18:39:38 -05:00
Peng Gao
640251ab91 Fix standard compatiblility
Non-nil but empty map with omitempty should be ignored.

Signed-off-by: Peng Gao <peng.gao.dut@gmail.com>
2017-10-27 01:43:41 +08:00
Tao Wen
06b2a7cf1d Merge pull request #188 from ggaaooppeenngg/compatible
Fix standard compatiblility
2017-10-26 06:41:01 -05:00
Peng Gao
5fffb9b8f7 Fix standard compatiblility
Encode has trailing newline at the end.

Signed-off-by: Peng Gao <peng.gao.dut@gmail.com>
2017-10-26 15:15:36 +08:00
Tao Wen
7e3b776024 change jsoniter-sloppy to jsoniter_sloppy 2017-10-23 15:03:44 +08:00
Tao Wen
6240e1e798 #185 add jsoniter.Valid 2017-10-10 08:57:02 +08:00
Tao Wen
0149a5cf4a fix #183 error message not only show expectation, but also the actual value 2017-10-09 08:24:51 +08:00
Tao Wen
5068c8baaf #183 limit error message size 2017-10-09 08:16:52 +08:00
Tao Wen
16f78601b5 fix #184, support null as number 2017-10-07 09:29:32 +08:00
Tao Wen
8f50a91be2 fix #181, support string as json.Number and jsoniter.Number 2017-10-06 18:08:14 +08:00
Tao Wen
73c7bc881e fix #180, add missing methods to jsoniter.Number 2017-10-06 17:56:36 +08:00
Tao Wen
4de15a3a87 Merge pull request #182 from MOZGIII/patch-1
Used writeTwoBytes in Stream.WriteEmptyArray
2017-10-04 02:25:32 -05:00
MOZGIII
14b28b2226 Used writeTwoBytes in Stream.WriteEmptyArray 2017-10-03 22:14:36 +03:00
Tao Wen
abe3c4016b fix #179 2017-09-26 15:35:55 +08:00
Tao Wen
dbb1ef3f63 #177 flush buffer should check available again 2017-09-21 21:04:45 +08:00
Tao Wen
46b20bbbec #178 SkipAndReturnBytes should return copy of memory 2017-09-21 20:18:45 +08:00
Tao Wen
fdfe0b9a69 Merge branch 'olegshaldybin-skip-unexported-fields' 2017-09-19 10:06:59 +08:00
Tao Wen
faa3dcf46a do not report error when field is unexported 2017-09-19 10:06:34 +08:00
Oleg Shaldybin
1f58120d43 Always skip unexported fields when encoding
Skip creating encoders for unexported fields. They are not participating
in JSON marshaling anyway. This allows using unexported fields of
non-marshalable types in structs.

As a side-effect of this change it's no longer possible to marshal
unexported JSON fields by adding a custom type extenstion. It seems this
is desired behavior since it matches standard library and jsoniter
already disallows `json:"-"` fields from participating in custom
extensions.

Fixes #174.
2017-09-18 11:02:15 -07:00
Tao Wen
6ed27152e0 Update README.md 2017-09-17 16:07:42 +08:00
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