RawExtension was not properly marshalled

MarshalJSON can't use a pointer to a struct for RawExtension:

http://stackoverflow.com/questions/21390979/custom-marshaljson-never-gets-called-in-go
This commit is contained in:
Clayton Coleman
2014-12-07 21:20:08 -05:00
parent 714dbf4522
commit 1eaa5c41f9
2 changed files with 42 additions and 1 deletions

View File

@@ -26,6 +26,8 @@ func (re *RawExtension) UnmarshalJSON(in []byte) error {
return nil
}
func (re *RawExtension) MarshalJSON() ([]byte, error) {
// Marshal may get called on pointers or values, so implement MarshalJSON on value.
// http://stackoverflow.com/questions/21390979/custom-marshaljson-never-gets-called-in-go
func (re RawExtension) MarshalJSON() ([]byte, error) {
return re.RawJSON, nil
}