本文整理汇总了Golang中github.com/pquerna/ffjson/fflib/v1.EncodingBuffer.Rewind方法的典型用法代码示例。如果您正苦于以下问题:Golang EncodingBuffer.Rewind方法的具体用法?Golang EncodingBuffer.Rewind怎么用?Golang EncodingBuffer.Rewind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/pquerna/ffjson/fflib/v1.EncodingBuffer
的用法示例。
在下文中一共展示了EncodingBuffer.Rewind方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: MarshalJSONBuf
func (mj *Event) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
var err error
var obj []byte
_ = obj
_ = err
buf.WriteString(`{"host":`)
fflib.WriteJsonString(buf, string(mj.Host))
buf.WriteString(`,"service":`)
fflib.WriteJsonString(buf, string(mj.Service))
buf.WriteString(`,"sub_service":`)
fflib.WriteJsonString(buf, string(mj.SubService))
buf.WriteString(`,"metric":`)
fflib.AppendFloat(buf, float64(mj.Metric), 'g', -1, 64)
if mj.Tags == nil {
buf.WriteString(`,"tags":null`)
} else {
buf.WriteString(`,"tags":{ `)
for key, value := range mj.Tags {
fflib.WriteJsonString(buf, key)
buf.WriteString(`:`)
fflib.WriteJsonString(buf, string(value))
buf.WriteByte(',')
}
buf.Rewind(1)
buf.WriteByte('}')
}
buf.WriteByte('}')
return nil
}
示例2: MarshalJSONBuf
func (mj *ResponseCountry) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
var err error
var obj []byte
_ = obj
_ = err
buf.WriteString(`{ `)
if mj.Data != nil {
if true {
buf.WriteString(`"Data":`)
{
err = mj.Data.MarshalJSONBuf(buf)
if err != nil {
return err
}
}
buf.WriteByte(',')
}
}
if len(mj.Error) != 0 {
buf.WriteString(`"Error":`)
fflib.WriteJsonString(buf, string(mj.Error))
buf.WriteByte(',')
}
buf.Rewind(1)
buf.WriteByte('}')
return nil
}
示例3: MarshalJSONBuf
func (mj *Error) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
if mj == nil {
buf.WriteString("null")
return nil
}
var err error
var obj []byte
_ = obj
_ = err
buf.WriteString(`{ "error":`)
fflib.WriteJsonString(buf, string(mj.Code))
buf.WriteByte(',')
if len(mj.Description) != 0 {
buf.WriteString(`"error_description":`)
fflib.WriteJsonString(buf, string(mj.Description))
buf.WriteByte(',')
}
if len(mj.URI) != 0 {
buf.WriteString(`"error_uri":`)
fflib.WriteJsonString(buf, string(mj.URI))
buf.WriteByte(',')
}
buf.Rewind(1)
buf.WriteByte('}')
return nil
}
示例4: MarshalJSONBuf
func (mj *TheCountry) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
var err error
var obj []byte
var scratch fflib.FormatBitsScratch
_ = scratch
_ = obj
_ = err
buf.WriteString(`{"GeoNameID":`)
fflib.FormatBits(&scratch, buf, uint64(mj.GeoNameID), 10, false)
buf.WriteString(`,"IsoCode":`)
fflib.WriteJsonString(buf, string(mj.IsoCode))
if mj.Names == nil {
buf.WriteString(`,"Names":null`)
} else {
buf.WriteString(`,"Names":{ `)
for key, value := range mj.Names {
fflib.WriteJsonString(buf, key)
buf.WriteString(`:`)
fflib.WriteJsonString(buf, string(value))
buf.WriteByte(',')
}
buf.Rewind(1)
buf.WriteByte('}')
}
buf.WriteByte('}')
return nil
}
示例5: MarshalJSONBuf
func (mj *Incident) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
var err error
var obj []byte
_ = obj
_ = err
buf.WriteString(`{"event":`)
if mj.EventName != nil {
buf.WriteString(`"`)
{
enc := base64.NewEncoder(base64.StdEncoding, buf)
enc.Write(reflect.Indirect(reflect.ValueOf(mj.EventName)).Bytes())
enc.Close()
}
buf.WriteString(`"`)
} else {
buf.WriteString(`null`)
}
buf.WriteString(`,"time":`)
fflib.FormatBits2(buf, uint64(mj.Time), 10, mj.Time < 0)
buf.WriteString(`,"id":`)
fflib.FormatBits2(buf, uint64(mj.Id), 10, mj.Id < 0)
if mj.Active {
buf.WriteString(`,"active":true`)
} else {
buf.WriteString(`,"active":false`)
}
buf.WriteString(`,"escalation":`)
fflib.WriteJsonString(buf, string(mj.Escalation))
buf.WriteString(`,"description":`)
fflib.WriteJsonString(buf, string(mj.Description))
buf.WriteString(`,"policy":`)
fflib.WriteJsonString(buf, string(mj.Policy))
buf.WriteString(`,"status":`)
fflib.FormatBits2(buf, uint64(mj.Status), 10, mj.Status < 0)
buf.WriteString(`,"host":`)
fflib.WriteJsonString(buf, string(mj.Host))
buf.WriteString(`,"service":`)
fflib.WriteJsonString(buf, string(mj.Service))
buf.WriteString(`,"sub_service":`)
fflib.WriteJsonString(buf, string(mj.SubService))
buf.WriteString(`,"metric":`)
fflib.AppendFloat(buf, float64(mj.Metric), 'g', -1, 64)
if mj.Tags == nil {
buf.WriteString(`,"tags":null`)
} else {
buf.WriteString(`,"tags":{ `)
for key, value := range mj.Tags {
fflib.WriteJsonString(buf, key)
buf.WriteString(`:`)
fflib.WriteJsonString(buf, string(value))
buf.WriteByte(',')
}
buf.Rewind(1)
buf.WriteByte('}')
}
buf.WriteByte('}')
return nil
}
示例6: MarshalJSONBuf
func (mj *Entry) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
var err error
var obj []byte
var scratch fflib.FormatBitsScratch
_ = scratch
_ = obj
_ = err
buf.WriteString(`{ "manufacturer":`)
fflib.WriteJsonString(buf, string(mj.Manufacturer))
buf.WriteString(`,"address":`)
if mj.Address != nil {
buf.WriteString(`[`)
for i, v := range mj.Address {
if i != 0 {
buf.WriteString(`,`)
}
fflib.WriteJsonString(buf, string(v))
}
buf.WriteString(`]`)
} else {
buf.WriteString(`null`)
}
buf.WriteString(`,"prefix":`)
{
obj, err = mj.Prefix.MarshalJSON()
if err != nil {
return err
}
buf.Write(obj)
}
buf.WriteByte(',')
if len(mj.Country) != 0 {
buf.WriteString(`"country":`)
fflib.WriteJsonString(buf, string(mj.Country))
buf.WriteByte(',')
}
if mj.Local != false {
if mj.Local {
buf.WriteString(`"local":true`)
} else {
buf.WriteString(`"local":false`)
}
buf.WriteByte(',')
}
if mj.Multicast != false {
if mj.Multicast {
buf.WriteString(`"multicast":true`)
} else {
buf.WriteString(`"multicast":false`)
}
buf.WriteByte(',')
}
buf.Rewind(1)
buf.WriteByte('}')
return nil
}
示例7: MarshalJSONBuf
func (mj *Event) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
if mj == nil {
buf.WriteString("null")
return nil
}
var err error
var obj []byte
_ = obj
_ = err
buf.WriteString(`{ "type":`)
fflib.WriteJsonString(buf, string(mj.Type))
buf.WriteByte(',')
if len(mj.Username) != 0 {
buf.WriteString(`"username":`)
fflib.WriteJsonString(buf, string(mj.Username))
buf.WriteByte(',')
}
if len(mj.Color) != 0 {
buf.WriteString(`"color":`)
fflib.WriteJsonString(buf, string(mj.Color))
buf.WriteByte(',')
}
if len(mj.Text) != 0 {
buf.WriteString(`"text":`)
fflib.WriteJsonString(buf, string(mj.Text))
buf.WriteByte(',')
}
if mj.TopicID != 0 {
buf.WriteString(`"topic-id":`)
fflib.FormatBits2(buf, uint64(mj.TopicID), 10, mj.TopicID < 0)
buf.WriteByte(',')
}
buf.WriteString(`"option-a":`)
fflib.WriteJsonString(buf, string(mj.OptionA))
buf.WriteString(`,"option-b":`)
fflib.WriteJsonString(buf, string(mj.OptionB))
buf.WriteByte(',')
if mj.VoteMask != 0 {
buf.WriteString(`"vote-mask":`)
fflib.FormatBits2(buf, uint64(mj.VoteMask), 10, false)
buf.WriteByte(',')
}
if len(mj.Error) != 0 {
buf.WriteString(`"error":`)
fflib.WriteJsonString(buf, string(mj.Error))
buf.WriteByte(',')
}
buf.Rewind(1)
buf.WriteByte('}')
return nil
}
示例8: MarshalJSONBuf
func (mj *SubmitOutput) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
var err error
var obj []byte
_ = obj
_ = err
if mj.Success {
buf.WriteString(`{ "success":true`)
} else {
buf.WriteString(`{ "success":false`)
}
buf.WriteByte(',')
if len(mj.Error) != 0 {
buf.WriteString(`"error":`)
fflib.WriteJsonString(buf, string(mj.Error))
buf.WriteByte(',')
}
buf.Rewind(1)
buf.WriteByte('}')
return nil
}
示例9: MarshalJSONBuf
func (mj *JSONError) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
if mj == nil {
buf.WriteString("null")
return nil
}
var err error
var obj []byte
_ = obj
_ = err
buf.WriteString(`{ `)
if mj.Status != 0 {
buf.WriteString(`"status":`)
fflib.FormatBits2(buf, uint64(mj.Status), 10, mj.Status < 0)
buf.WriteByte(',')
}
if len(mj.Code) != 0 {
buf.WriteString(`"code":`)
fflib.WriteJsonString(buf, string(mj.Code))
buf.WriteByte(',')
}
if len(mj.Type) != 0 {
buf.WriteString(`"type":`)
fflib.WriteJsonString(buf, string(mj.Type))
buf.WriteByte(',')
}
if len(mj.Message) != 0 {
buf.WriteString(`"message":`)
fflib.WriteJsonString(buf, string(mj.Message))
buf.WriteByte(',')
}
if len(mj.MoreInfo) != 0 {
buf.WriteString(`"moreInfo":`)
fflib.WriteJsonString(buf, string(mj.MoreInfo))
buf.WriteByte(',')
}
buf.Rewind(1)
buf.WriteByte('}')
return nil
}
示例10: MarshalJSONBuf
func (mj *TokenResponse) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
if mj == nil {
buf.WriteString("null")
return nil
}
var err error
var obj []byte
_ = obj
_ = err
buf.WriteString(`{ "access_token":`)
fflib.WriteJsonString(buf, string(mj.AccessToken))
buf.WriteString(`,"token_type":`)
fflib.WriteJsonString(buf, string(mj.TokenType))
buf.WriteByte(',')
if mj.ExpiresIn != 0 {
buf.WriteString(`"expires_in":`)
fflib.FormatBits2(buf, uint64(mj.ExpiresIn), 10, mj.ExpiresIn < 0)
buf.WriteByte(',')
}
if len(mj.RefreshToken) != 0 {
buf.WriteString(`"refresh_token":`)
fflib.WriteJsonString(buf, string(mj.RefreshToken))
buf.WriteByte(',')
}
if len(mj.Scope) != 0 {
buf.WriteString(`"scope":`)
fflib.WriteJsonString(buf, string(mj.Scope))
buf.WriteByte(',')
}
if len(mj.State) != 0 {
buf.WriteString(`"state":`)
fflib.WriteJsonString(buf, string(mj.State))
buf.WriteByte(',')
}
buf.Rewind(1)
buf.WriteByte('}')
return nil
}
示例11: MarshalJSONBuf
//.........这里部分代码省略.........
fflib.WriteJsonString(buf, string(v.ValueOneLifeMax))
buf.WriteString(`,"last_save":`)
fflib.WriteJsonString(buf, string(v.LastSave))
buf.WriteByte('}')
}
buf.WriteString(`]`)
} else {
buf.WriteString(`null`)
}
buf.WriteString(`,"stat_history":`)
if mj.Stats.StatHistory != nil {
buf.WriteString(`[`)
for i, v := range mj.Stats.StatHistory {
if i != 0 {
buf.WriteString(`,`)
}
/* Inline struct. type=struct { Name string "json:\"stat_name\""; AllTime string "json:\"all_time\""; OneLifeMax string "json:\"one_life_max\""; Day map[string]string "json:\"day\""; Month map[string]string "json:\"Month\""; Week map[string]string "json:\"Week\"" } kind=struct */
buf.WriteString(`{ "stat_name":`)
fflib.WriteJsonString(buf, string(v.Name))
buf.WriteString(`,"all_time":`)
fflib.WriteJsonString(buf, string(v.AllTime))
buf.WriteString(`,"one_life_max":`)
fflib.WriteJsonString(buf, string(v.OneLifeMax))
if v.Day == nil {
buf.WriteString(`,"day":null`)
} else {
buf.WriteString(`,"day":{ `)
for key, value := range v.Day {
fflib.WriteJsonString(buf, key)
buf.WriteString(`:`)
fflib.WriteJsonString(buf, string(value))
buf.WriteByte(',')
}
buf.Rewind(1)
buf.WriteByte('}')
}
if v.Month == nil {
buf.WriteString(`,"Month":null`)
} else {
buf.WriteString(`,"Month":{ `)
for key, value := range v.Month {
fflib.WriteJsonString(buf, key)
buf.WriteString(`:`)
fflib.WriteJsonString(buf, string(value))
buf.WriteByte(',')
}
buf.Rewind(1)
buf.WriteByte('}')
}
if v.Week == nil {
buf.WriteString(`,"Week":null`)
} else {
buf.WriteString(`,"Week":{ `)
for key, value := range v.Week {
fflib.WriteJsonString(buf, key)
buf.WriteString(`:`)
fflib.WriteJsonString(buf, string(value))
buf.WriteByte(',')
}
buf.Rewind(1)
buf.WriteByte('}')
}
buf.WriteByte('}')
}
buf.WriteString(`]`)
} else {