You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We had a discussion about this recently with the CloudEvent type - we didn't want to expose json.RawMessage since it'd potentially cause issues in the future when a new JSON package comes around.
I think it's as simple as using a []byte() around the returned value since json.RawMessage == []byte.
func (e*Event) UnmarshalJSON(data []byte) error {
varrawMsgmap[string]json.RawMessageiferr:=json.Unmarshal(data, &rawMsg); err!=nil {
returnfmt.Errorf("unmarshalling type %T: %v", e, err)
}
forkey, val:=rangerawMsg {
varerrerrorswitchkey {
case"data":
e.Data=val// <--- I believe this is incorrect - we don't want to surface json.RawMessage as a type. delete(rawMsg, key)
The text was updated successfully, but these errors were encountered:
If you choose raw-json-as-bytes Data is also changed to be of type []byte, making the assignment I outlined above safe. So we can close this one and I lose my dreams of filing a valid autorest bug.
We had a discussion about this recently with the CloudEvent type - we didn't want to expose json.RawMessage since it'd potentially cause issues in the future when a new JSON package comes around.
I think it's as simple as using a []byte() around the returned value since json.RawMessage == []byte.
The text was updated successfully, but these errors were encountered: