mirror of
https://github.com/json-iterator/go.git
synced 2024-11-27 08:30:57 +02:00
parent
acfec88f7a
commit
3987001e27
@ -183,11 +183,11 @@ func (cfg *frozenConfig) validateJsonRawMessage(extension EncoderExtension) {
|
|||||||
encoder := &funcEncoder{func(ptr unsafe.Pointer, stream *Stream) {
|
encoder := &funcEncoder{func(ptr unsafe.Pointer, stream *Stream) {
|
||||||
rawMessage := *(*json.RawMessage)(ptr)
|
rawMessage := *(*json.RawMessage)(ptr)
|
||||||
iter := cfg.BorrowIterator([]byte(rawMessage))
|
iter := cfg.BorrowIterator([]byte(rawMessage))
|
||||||
|
defer cfg.ReturnIterator(iter)
|
||||||
iter.Read()
|
iter.Read()
|
||||||
if iter.Error != nil {
|
if iter.Error != nil && iter.Error != io.EOF {
|
||||||
stream.WriteRaw("null")
|
stream.WriteRaw("null")
|
||||||
} else {
|
} else {
|
||||||
cfg.ReturnIterator(iter)
|
|
||||||
stream.WriteRaw(string(rawMessage))
|
stream.WriteRaw(string(rawMessage))
|
||||||
}
|
}
|
||||||
}, func(ptr unsafe.Pointer) bool {
|
}, func(ptr unsafe.Pointer) bool {
|
||||||
|
@ -7,6 +7,9 @@ import (
|
|||||||
func init() {
|
func init() {
|
||||||
marshalCases = append(marshalCases,
|
marshalCases = append(marshalCases,
|
||||||
json.RawMessage("{}"),
|
json.RawMessage("{}"),
|
||||||
|
json.RawMessage("12345"),
|
||||||
|
json.RawMessage("3.14"),
|
||||||
|
json.RawMessage("-0.5e10"),
|
||||||
struct {
|
struct {
|
||||||
Env string `json:"env"`
|
Env string `json:"env"`
|
||||||
Extra json.RawMessage `json:"extra,omitempty"`
|
Extra json.RawMessage `json:"extra,omitempty"`
|
||||||
|
Loading…
Reference in New Issue
Block a user