Skip to content

Commit

Permalink
Merge pull request #432 from AllenX2018/fix-raw-message-integer-issue
Browse files Browse the repository at this point in the history
fix issue #389 #411
  • Loading branch information
AllenX2018 authored Feb 6, 2020
2 parents 69f2a91 + 3987001 commit 7acbb40
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions value_tests/raw_message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down

0 comments on commit 7acbb40

Please sign in to comment.