如何定制json序列化
Marshal
traverses the value v recursively.
If an encountered value implements the
Marshaler
interface and is not a nil pointer, Marshal calls itsMarshalJSON
method to produce JSON.If no MarshalJSON method is present but the value implements
encoding.TextMarshaler
instead, Marshal calls itsMarshalText
method and encodes the result as a JSON string
也就是说,对于自定义类型,要支持json序列化,要实现以下接口:
Last updated