mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-06 22:43:10 -06:00
Comments for why we don't json.marshal the InputRoomEvent directly
This commit is contained in:
parent
1082b2adf3
commit
e7f859978a
|
|
@ -50,6 +50,8 @@ type InputRoomEvent struct {
|
|||
|
||||
// UnmarshalJSON implements json.Unmarshaller
|
||||
func (ire *InputRoomEvent) UnmarshalJSON(data []byte) error {
|
||||
// Create a struct rather than unmarshalling directly into the InputRoomEvent
|
||||
// so that we can use json.RawMessage.
|
||||
var content struct {
|
||||
Kind int
|
||||
Event *json.RawMessage
|
||||
|
|
@ -72,6 +74,8 @@ func (ire *InputRoomEvent) UnmarshalJSON(data []byte) error {
|
|||
|
||||
// MarshalJSON implements json.Marshaller
|
||||
func (ire InputRoomEvent) MarshalJSON() ([]byte, error) {
|
||||
// Create a struct rather than marshalling directly from the InputRoomEvent
|
||||
// so that we can use json.RawMessage.
|
||||
event := json.RawMessage(ire.Event)
|
||||
content := struct {
|
||||
Kind int
|
||||
|
|
|
|||
Loading…
Reference in a new issue