當前位置: 首頁>>代碼示例>>Golang>>正文


Golang jwriter.Writer類代碼示例

本文整理匯總了Golang中github.com/mailru/easyjson/jwriter.Writer的典型用法代碼示例。如果您正苦於以下問題:Golang Writer類的具體用法?Golang Writer怎麽用?Golang Writer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Writer類的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: MarshalEasyJSON

// MarshalEasyJSON does JSON marshaling using easyjson interface.
func (v Float64) MarshalEasyJSON(w *jwriter.Writer) {
	if v.Defined {
		w.Float64(v.V)
	} else {
		w.RawString("null")
	}
}
開發者ID:,項目名稱:,代碼行數:8,代碼來源:

示例2: 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)
}
開發者ID:kubernetes,項目名稱:dashboard,代碼行數:13,代碼來源:json.go

示例3: easyjson_encode_github_com_buger_jsonparser_benchmark_CBGithub

func easyjson_encode_github_com_buger_jsonparser_benchmark_CBGithub(out *jwriter.Writer, in *CBGithub) {
	out.RawByte('{')
	first := true
	_ = first
	if !first {
		out.RawByte(',')
	}
	first = false
	out.RawString("\"followers\":")
	out.Int(in.Followers)
	out.RawByte('}')
}
開發者ID:qband,項目名稱:down,代碼行數:12,代碼來源:benchmark_easyjson.go

示例4: easyjson_encode_github_com_buger_jsonparser_benchmark_DSUser

func easyjson_encode_github_com_buger_jsonparser_benchmark_DSUser(out *jwriter.Writer, in *DSUser) {
	out.RawByte('{')
	first := true
	_ = first
	if !first {
		out.RawByte(',')
	}
	first = false
	out.RawString("\"username\":")
	out.String(in.Username)
	out.RawByte('}')
}
開發者ID:qband,項目名稱:down,代碼行數:12,代碼來源:benchmark_easyjson.go

示例5: easyjson_encode_github_com_buger_jsonparser_benchmark_CBName

func easyjson_encode_github_com_buger_jsonparser_benchmark_CBName(out *jwriter.Writer, in *CBName) {
	out.RawByte('{')
	first := true
	_ = first
	if !first {
		out.RawByte(',')
	}
	first = false
	out.RawString("\"full_name\":")
	out.String(in.FullName)
	out.RawByte('}')
}
開發者ID:qband,項目名稱:down,代碼行數:12,代碼來源:benchmark_easyjson.go

示例6: easyjson_encode_github_com_buger_jsonparser_benchmark_CBAvatar

func easyjson_encode_github_com_buger_jsonparser_benchmark_CBAvatar(out *jwriter.Writer, in *CBAvatar) {
	out.RawByte('{')
	first := true
	_ = first
	if !first {
		out.RawByte(',')
	}
	first = false
	out.RawString("\"url\":")
	out.String(in.Url)
	out.RawByte('}')
}
開發者ID:qband,項目名稱:down,代碼行數:12,代碼來源:benchmark_easyjson.go

示例7: MarshalToHTTPResponseWriter

// MarshalToHTTPResponseWriter sets Content-Length and Content-Type headers for the
// http.ResponseWriter, and send the data to the writer. started will be equal to
// false if an error occurred before any http.ResponseWriter methods were actually
// invoked (in this case a 500 reply is possible).
func MarshalToHTTPResponseWriter(v Marshaler, w http.ResponseWriter) (started bool, written int, err error) {
	jw := jwriter.Writer{}
	v.MarshalEasyJSON(&jw)
	if jw.Error != nil {
		return false, 0, jw.Error
	}
	w.Header().Set("Content-Type", "application/json")
	w.Header().Set("Content-Length", strconv.Itoa(jw.Size()))

	started = true
	written, err = jw.DumpTo(w)
	return
}
開發者ID:,項目名稱:,代碼行數:17,代碼來源:

示例8: BenchmarkEJ_Marshal_M_ToWriter

func BenchmarkEJ_Marshal_M_ToWriter(b *testing.B) {
	var l int64
	out := &DummyWriter{}
	for i := 0; i < b.N; i++ {
		w := jwriter.Writer{}
		largeStructData.MarshalEasyJSON(&w)
		if w.Error != nil {
			b.Error(w.Error)
		}

		l = int64(w.Size())
		w.DumpTo(out)
	}
	b.SetBytes(l)

}
開發者ID:,項目名稱:,代碼行數:16,代碼來源:

示例9: BenchmarkEJ_Marshal_L_ToWriter_Parallel

func BenchmarkEJ_Marshal_L_ToWriter_Parallel(b *testing.B) {
	out := &DummyWriter{}
	b.RunParallel(func(pb *testing.PB) {
		var l int64
		for pb.Next() {
			w := jwriter.Writer{}

			xlStructData.MarshalEasyJSON(&w)
			if w.Error != nil {
				b.Error(w.Error)
			}
			l = int64(w.Size())
			w.DumpTo(out)
		}
		if l > 0 {
			b.SetBytes(l)
		}
	})
}
開發者ID:,項目名稱:,代碼行數:19,代碼來源:

示例10: easyjson_encode_finance_provider_yahoo_Response

func easyjson_encode_finance_provider_yahoo_Response(out *jwriter.Writer, in *Response) {
	out.RawByte('{')
	first := true
	_ = first
	if !first {
		out.RawByte(',')
	}
	first = false
	out.RawString("\"query\":")
	(in.Query).MarshalEasyJSON(out)
	out.RawByte('}')
}
開發者ID:gobwas,項目名稱:kursobot,代碼行數:12,代碼來源:types_easyjson.go

示例11: MarshalEasyJSON

func (e Email) MarshalEasyJSON(w *jwriter.Writer) {
	w.String(string(e))
}
開發者ID:Cl0udPhish,項目名稱:go-swagger,代碼行數:3,代碼來源:default.go

示例12: MarshalJSON

func (e Email) MarshalJSON() ([]byte, error) {
	var w jwriter.Writer
	e.MarshalEasyJSON(&w)
	return w.BuildBytes()
}
開發者ID:Cl0udPhish,項目名稱:go-swagger,代碼行數:5,代碼來源:default.go

示例13: easyjson_encode_go_serialization_benchmarks_A

func easyjson_encode_go_serialization_benchmarks_A(out *jwriter.Writer, in *A) {
	out.RawByte('{')
	first := true
	_ = first
	if !first {
		out.RawByte(',')
	}
	first = false
	out.RawString("\"Name\":")
	out.String(in.Name)
	if !first {
		out.RawByte(',')
	}
	first = false
	out.RawString("\"BirthDay\":")
	out.Raw((in.BirthDay).MarshalJSON())
	if !first {
		out.RawByte(',')
	}
	first = false
	out.RawString("\"Phone\":")
	out.String(in.Phone)
	if !first {
		out.RawByte(',')
	}
	first = false
	out.RawString("\"Siblings\":")
	out.Int(in.Siblings)
	if !first {
		out.RawByte(',')
	}
	first = false
	out.RawString("\"Spouse\":")
	out.Bool(in.Spouse)
	if !first {
		out.RawByte(',')
	}
	first = false
	out.RawString("\"Money\":")
	out.Float64(in.Money)
	out.RawByte('}')
}
開發者ID:alecthomas,項目名稱:go_serialization_benchmarks,代碼行數:42,代碼來源:structdef_easyjson.go


注:本文中的github.com/mailru/easyjson/jwriter.Writer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。