本文整理匯總了Golang中github.com/mailru/easyjson/jwriter.Writer.BuildBytes方法的典型用法代碼示例。如果您正苦於以下問題:Golang Writer.BuildBytes方法的具體用法?Golang Writer.BuildBytes怎麽用?Golang Writer.BuildBytes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/mailru/easyjson/jwriter.Writer
的用法示例。
在下文中一共展示了Writer.BuildBytes方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: WriteJSON
// WriteJSON writes json data, prefers finding an appropriate interface to short-circuit the marshaller
// so it takes the fastest option available.
func WriteJSON(data interface{}) ([]byte, error) {
if d, ok := data.(ejMarshaler); ok {
jw := new(jwriter.Writer)
d.MarshalEasyJSON(jw)
return jw.BuildBytes()
}
if d, ok := data.(json.Marshaler); ok {
return d.MarshalJSON()
}
return json.Marshal(data)
}
示例2: MarshalJSON
func (u ISBN10) MarshalJSON() ([]byte, error) {
var w jwriter.Writer
u.MarshalEasyJSON(&w)
return w.BuildBytes()
}
示例3: MarshalJSON
func (t DateTime) MarshalJSON() ([]byte, error) {
var w jwriter.Writer
t.MarshalEasyJSON(&w)
return w.BuildBytes()
}
示例4: Marshal
// Marshal returns data as a single byte slice. Method is suboptimal as the data is likely to be copied
// from a chain of smaller chunks.
func Marshal(v Marshaler) ([]byte, error) {
w := jwriter.Writer{}
v.MarshalEasyJSON(&w)
return w.BuildBytes()
}
示例5: MarshalJSON
func (d Duration) MarshalJSON() ([]byte, error) {
var w jwriter.Writer
d.MarshalEasyJSON(&w)
return w.BuildBytes()
}