1
0
mirror of https://github.com/json-iterator/go.git synced 2025-04-20 11:28:49 +02:00

Merge pull request #432 from AllenX2018/fix-raw-message-integer-issue

fix issue #389 #411
This commit is contained in:
Allen 2020-02-06 09:56:04 +08:00 committed by GitHub
commit 7acbb404a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -183,11 +183,11 @@ func (cfg *frozenConfig) validateJsonRawMessage(extension EncoderExtension) {
encoder := &funcEncoder{func(ptr unsafe.Pointer, stream *Stream) {
rawMessage := *(*json.RawMessage)(ptr)
iter := cfg.BorrowIterator([]byte(rawMessage))
defer cfg.ReturnIterator(iter)
iter.Read()
if iter.Error != nil {
if iter.Error != nil && iter.Error != io.EOF {
stream.WriteRaw("null")
} else {
cfg.ReturnIterator(iter)
stream.WriteRaw(string(rawMessage))
}
}, func(ptr unsafe.Pointer) bool {

View File

@ -7,6 +7,9 @@ import (
func init() {
marshalCases = append(marshalCases,
json.RawMessage("{}"),
json.RawMessage("12345"),
json.RawMessage("3.14"),
json.RawMessage("-0.5e10"),
struct {
Env string `json:"env"`
Extra json.RawMessage `json:"extra,omitempty"`