// 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) }
func (u ISBN10) MarshalJSON() ([]byte, error) { var w jwriter.Writer u.MarshalEasyJSON(&w) return w.BuildBytes() }
func (h Hostname) MarshalJSON() ([]byte, error) { var w jwriter.Writer h.MarshalEasyJSON(&w) return w.BuildBytes() }
func (e Email) MarshalJSON() ([]byte, error) { var w jwriter.Writer e.MarshalEasyJSON(&w) return w.BuildBytes() }
func (b Base64) MarshalJSON() ([]byte, error) { var w jwriter.Writer b.MarshalEasyJSON(&w) return w.BuildBytes() }
func (r Password) MarshalJSON() ([]byte, error) { var w jwriter.Writer r.MarshalEasyJSON(&w) return w.BuildBytes() }
func (u CreditCard) MarshalJSON() ([]byte, error) { var w jwriter.Writer u.MarshalEasyJSON(&w) return w.BuildBytes() }
func (t DateTime) MarshalJSON() ([]byte, error) { var w jwriter.Writer t.MarshalEasyJSON(&w) return w.BuildBytes() }
// 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() }
func (d Duration) MarshalJSON() ([]byte, error) { var w jwriter.Writer d.MarshalEasyJSON(&w) return w.BuildBytes() }