Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalWithExtensions ¶
marshalWithExtensions marshals a struct with extensions inlined. This is a helper for custom MarshalJSON implementations.
IMPORTANT: When calling this function, the caller MUST use a type alias to avoid infinite recursion. For example,
func (s *MyStruct) MarshalJSON() ([]byte, error) {
type myStruct MyStruct // Type alias prevents recursion
return marshalWithExtensions(myStruct(*s), s.Extensions)
}
Without the type alias, json.Marshal would recursively call MarshalJSON on the same type, causing infinite recursion. The type alias creates a new type that doesn't have the MarshalJSON method, allowing standard JSON marshaling to proceed.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.