From e7f859978ae2c01426fa613e5dc1c94d6422de51 Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Wed, 22 Feb 2017 15:21:14 +0000 Subject: [PATCH] Comments for why we don't json.marshal the InputRoomEvent directly --- src/github.com/matrix-org/dendrite/roomserver/api/input.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/github.com/matrix-org/dendrite/roomserver/api/input.go b/src/github.com/matrix-org/dendrite/roomserver/api/input.go index 585dadd4d..71d0b0e59 100644 --- a/src/github.com/matrix-org/dendrite/roomserver/api/input.go +++ b/src/github.com/matrix-org/dendrite/roomserver/api/input.go @@ -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