mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-07 06:53:09 -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
|
// UnmarshalJSON implements json.Unmarshaller
|
||||||
func (ire *InputRoomEvent) UnmarshalJSON(data []byte) error {
|
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 {
|
var content struct {
|
||||||
Kind int
|
Kind int
|
||||||
Event *json.RawMessage
|
Event *json.RawMessage
|
||||||
|
|
@ -72,6 +74,8 @@ func (ire *InputRoomEvent) UnmarshalJSON(data []byte) error {
|
||||||
|
|
||||||
// MarshalJSON implements json.Marshaller
|
// MarshalJSON implements json.Marshaller
|
||||||
func (ire InputRoomEvent) MarshalJSON() ([]byte, error) {
|
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)
|
event := json.RawMessage(ire.Event)
|
||||||
content := struct {
|
content := struct {
|
||||||
Kind int
|
Kind int
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue