You've already forked json-iterator
							
							
				mirror of
				https://github.com/json-iterator/go.git
				synced 2025-10-31 00:07:40 +02:00 
			
		
		
		
	fix #291 omit empty was not handled properly for json raw message
This commit is contained in:
		| @@ -191,7 +191,7 @@ func (cfg *frozenConfig) validateJsonRawMessage(extension EncoderExtension) { | ||||
| 			stream.WriteRaw(string(rawMessage)) | ||||
| 		} | ||||
| 	}, func(ptr unsafe.Pointer) bool { | ||||
| 		return false | ||||
| 		return len(*((*json.RawMessage)(ptr))) == 0 | ||||
| 	}} | ||||
| 	extension[reflect2.TypeOfPtr((*json.RawMessage)(nil)).Elem()] = encoder | ||||
| 	extension[reflect2.TypeOfPtr((*RawMessage)(nil)).Elem()] = encoder | ||||
|   | ||||
| @@ -1,10 +1,18 @@ | ||||
| package test | ||||
|  | ||||
| import "encoding/json" | ||||
| import ( | ||||
| 	"encoding/json" | ||||
| ) | ||||
|  | ||||
| func init() { | ||||
| 	marshalCases = append(marshalCases, | ||||
| 		json.RawMessage("{}"), | ||||
| 		selectedMarshalCase{struct { | ||||
| 			Env   string          `json:"env"` | ||||
| 			Extra json.RawMessage `json:"extra,omitempty"` | ||||
| 		}{ | ||||
| 			Env: "jfdk", | ||||
| 		}}, | ||||
| 	) | ||||
| 	unmarshalCases = append(unmarshalCases, unmarshalCase{ | ||||
| 		ptr:   (*json.RawMessage)(nil), | ||||
|   | ||||
		Reference in New Issue
	
	Block a user