本文整理汇总了Golang中github.com/pquerna/ffjson/fflib/v1.EncodingBuffer.Write方法的典型用法代码示例。如果您正苦于以下问题:Golang EncodingBuffer.Write方法的具体用法?Golang EncodingBuffer.Write怎么用?Golang EncodingBuffer.Write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/pquerna/ffjson/fflib/v1.EncodingBuffer
的用法示例。
在下文中一共展示了EncodingBuffer.Write方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: MarshalJSONBuf
func (mj *InMsg) 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.WriteString(`,"data":`)
{
obj, err = mj.Data.MarshalJSON()
if err != nil {
return err
}
buf.Write(obj)
}
buf.WriteByte('}')
return nil
}
示例2: MarshalJSONBuf
func (mj *LogFormat) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
if mj == nil {
buf.WriteString("null")
return nil
}
var err error
var obj []byte
_ = obj
_ = err
buf.WriteString(`{"Prefix":`)
fflib.WriteJsonString(buf, string(mj.Prefix))
buf.WriteString(`,"Time":`)
{
obj, err = mj.Time.MarshalJSON()
if err != nil {
return err
}
buf.Write(obj)
}
buf.WriteString(`,"Host":`)
fflib.WriteJsonString(buf, string(mj.Host))
buf.WriteString(`,"Level":`)
fflib.FormatBits2(buf, uint64(mj.Level), 10, false)
buf.WriteString(`,"Msg":`)
fflib.WriteJsonString(buf, string(mj.Msg))
buf.WriteString(`,"Caller":`)
fflib.WriteJsonString(buf, string(mj.Caller))
buf.WriteString(`,"LineNo":`)
fflib.FormatBits2(buf, uint64(mj.LineNo), 10, mj.LineNo < 0)
buf.WriteByte('}')
return nil
}
示例3: 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
}
示例4: MarshalJSONBuf
func (mj *Location) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
var err error
var obj []byte
var scratch fflib.FormatBitsScratch
_ = scratch
_ = obj
_ = err
buf.WriteString(`{"Latitude":`)
buf.Write(strconv.AppendFloat([]byte{}, mj.Latitude, 'g', -1, 64))
buf.WriteString(`,"Longitude":`)
buf.Write(strconv.AppendFloat([]byte{}, mj.Longitude, 'g', -1, 64))
buf.WriteString(`,"MetroCode":`)
fflib.FormatBits(&scratch, buf, uint64(mj.MetroCode), 10, false)
buf.WriteString(`,"TimeZone":`)
fflib.WriteJsonString(buf, string(mj.TimeZone))
buf.WriteByte('}')
return nil
}
示例5: MarshalJSONBuf
func (mj *Topic) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
if mj == nil {
buf.WriteString("null")
return nil
}
var err error
var obj []byte
_ = obj
_ = err
buf.WriteString(`{"option-a":`)
fflib.WriteJsonString(buf, string(mj.OptionA))
buf.WriteString(`,"option-b":`)
fflib.WriteJsonString(buf, string(mj.OptionB))
buf.WriteString(`,"id":`)
fflib.FormatBits2(buf, uint64(mj.ID), 10, mj.ID < 0)
buf.WriteString(`,"created":`)
{
obj, err = mj.Created.MarshalJSON()
if err != nil {
return err
}
buf.Write(obj)
}
buf.WriteString(`,"ends":`)
{
obj, err = mj.Ends.MarshalJSON()
if err != nil {
return err
}
buf.Write(obj)
}
buf.WriteByte('}')
return nil
}
示例6: MarshalJSONBuf
func (mj *User) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
var err error
var obj []byte
_ = obj
_ = err
buf.WriteString(`{"ID":`)
fflib.FormatBits2(buf, uint64(mj.ID), 10, mj.ID < 0)
buf.WriteString(`,"Name":`)
fflib.WriteJsonString(buf, string(mj.Name))
buf.WriteString(`,"Age":`)
fflib.FormatBits2(buf, uint64(mj.Age), 10, mj.Age < 0)
buf.WriteString(`,"Created":`)
{
obj, err = mj.Created.MarshalJSON()
if err != nil {
return err
}
buf.Write(obj)
}
buf.WriteByte('}')
return nil
}
示例7: MarshalJSONBuf
func (mj *Character) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
if mj == nil {
buf.WriteString("null")
return nil
}
var err error
var obj []byte
_ = obj
_ = err
buf.WriteString(`{"character_id":`)
fflib.WriteJsonString(buf, string(mj.ID))
/* Inline struct. type=struct { First string "json:\"first\""; Lower string "json:\"first_lower\"" } kind=struct */
buf.WriteString(`,"name":{ "first":`)
fflib.WriteJsonString(buf, string(mj.Name.First))
buf.WriteString(`,"first_lower":`)
fflib.WriteJsonString(buf, string(mj.Name.Lower))
buf.WriteByte('}')
buf.WriteString(`,"faction_id":`)
fflib.WriteJsonString(buf, string(mj.FactionID))
buf.WriteString(`,"title_id":`)
fflib.WriteJsonString(buf, string(mj.TitleID))
/* Inline struct. type=struct { Creation string "json:\"creation\""; LastSave string "json:\"last_save\""; LastLogin string "json:\"last_login\""; LoginCount string "json:\"login_count\""; MinutesPlayed string "json:\"minutes_played\"" } kind=struct */
buf.WriteString(`,"times":{ "creation":`)
fflib.WriteJsonString(buf, string(mj.Times.Creation))
buf.WriteString(`,"last_save":`)
fflib.WriteJsonString(buf, string(mj.Times.LastSave))
buf.WriteString(`,"last_login":`)
fflib.WriteJsonString(buf, string(mj.Times.LastLogin))
buf.WriteString(`,"login_count":`)
fflib.WriteJsonString(buf, string(mj.Times.LoginCount))
buf.WriteString(`,"minutes_played":`)
fflib.WriteJsonString(buf, string(mj.Times.MinutesPlayed))
buf.WriteByte('}')
/* Inline struct. type=struct { Earned string "json:\"earned_points\""; Gifted string "json:\"gifted_points\""; Spent string "json:\"spent_points\""; Available string "json:\"available_points\""; PercentToNext string "json:\"percent_to_next\"" } kind=struct */
buf.WriteString(`,"certs":{ "earned_points":`)
fflib.WriteJsonString(buf, string(mj.Certs.Earned))
buf.WriteString(`,"gifted_points":`)
fflib.WriteJsonString(buf, string(mj.Certs.Gifted))
buf.WriteString(`,"spent_points":`)
fflib.WriteJsonString(buf, string(mj.Certs.Spent))
buf.WriteString(`,"available_points":`)
fflib.WriteJsonString(buf, string(mj.Certs.Available))
buf.WriteString(`,"percent_to_next":`)
fflib.WriteJsonString(buf, string(mj.Certs.PercentToNext))
buf.WriteByte('}')
/* Inline struct. type=struct { Rank string "json:\"value\""; PercentToNext string "json:\"percent_to_next\"" } kind=struct */
buf.WriteString(`,"battle_rank":{ "value":`)
fflib.WriteJsonString(buf, string(mj.Battlerank.Rank))
buf.WriteString(`,"percent_to_next":`)
fflib.WriteJsonString(buf, string(mj.Battlerank.PercentToNext))
buf.WriteByte('}')
/* Inline struct. type=struct { Count string "json:\"count\""; Time string "json:\"time\"" } kind=struct */
buf.WriteString(`,"daily_ribbon":{ "count":`)
fflib.WriteJsonString(buf, string(mj.DailyRibbon.Count))
buf.WriteString(`,"time":`)
fflib.WriteJsonString(buf, string(mj.DailyRibbon.Time))
buf.WriteByte('}')
buf.WriteString(`,"profile_id":`)
fflib.WriteJsonString(buf, string(mj.ProfileID))
/* Inline struct. type=struct { ID string "json:\"outfit_id\""; Name string "json:\"name\""; Alias string "json:\"alias\""; LeaderID string "json:\"leader_character_id\""; MemberCount string "json:\"member_count\""; TimeCreated string "json:\"time_created\"" } kind=struct */
buf.WriteString(`,"outfit":{ "outfit_id":`)
fflib.WriteJsonString(buf, string(mj.Outfit.ID))
buf.WriteString(`,"name":`)
fflib.WriteJsonString(buf, string(mj.Outfit.Name))
buf.WriteString(`,"alias":`)
fflib.WriteJsonString(buf, string(mj.Outfit.Alias))
buf.WriteString(`,"leader_character_id":`)
fflib.WriteJsonString(buf, string(mj.Outfit.LeaderID))
buf.WriteString(`,"member_count":`)
fflib.WriteJsonString(buf, string(mj.Outfit.MemberCount))
buf.WriteString(`,"time_created":`)
fflib.WriteJsonString(buf, string(mj.Outfit.TimeCreated))
buf.WriteByte('}')
buf.WriteString(`,"online_status":`)
fflib.WriteJsonString(buf, string(mj.OnlineStatus))
/* Inline struct. type=struct { Stat []struct { Name string "json:\"stat_name\""; ProfileID string "json:\"profile_id\""; ValueForever string "json:\"value_forever\""; ValueMonthly string "json:\"value_monthly\""; ValueWeekly string "json:\"value_weekly\""; ValueDaily string "json:\"value_daily\""; ValueOneLifeMax string "json:\"value_one_life_max\""; LastSave string "json:\"last_save\"" } "json:\"stat\""; StatHistory []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\"" } "json:\"stat_history\""; WeaponStat []struct { Name string "json:\"weapon_deaths\""; ItemID string "json:\"item_id\""; VehicleID string "json:\"vehicle_id\""; Value string "json:\"value\""; LastSave string "json:\"last_save\"" } "json:\"weapon_stat\"" } kind=struct */
buf.WriteString(`,"stats":{ "stat":`)
if mj.Stats.Stat != nil {
buf.WriteString(`[`)
for i, v := range mj.Stats.Stat {
if i != 0 {
buf.WriteString(`,`)
}
/* Inline struct. type=struct { Name string "json:\"stat_name\""; ProfileID string "json:\"profile_id\""; ValueForever string "json:\"value_forever\""; ValueMonthly string "json:\"value_monthly\""; ValueWeekly string "json:\"value_weekly\""; ValueDaily string "json:\"value_daily\""; ValueOneLifeMax string "json:\"value_one_life_max\""; LastSave string "json:\"last_save\"" } kind=struct */
buf.WriteString(`{ "stat_name":`)
fflib.WriteJsonString(buf, string(v.Name))
buf.WriteString(`,"profile_id":`)
fflib.WriteJsonString(buf, string(v.ProfileID))
buf.WriteString(`,"value_forever":`)
fflib.WriteJsonString(buf, string(v.ValueForever))
buf.WriteString(`,"value_monthly":`)
fflib.WriteJsonString(buf, string(v.ValueMonthly))
buf.WriteString(`,"value_weekly":`)
fflib.WriteJsonString(buf, string(v.ValueWeekly))
buf.WriteString(`,"value_daily":`)
fflib.WriteJsonString(buf, string(v.ValueDaily))
buf.WriteString(`,"value_one_life_max":`)
fflib.WriteJsonString(buf, string(v.ValueOneLifeMax))
buf.WriteString(`,"last_save":`)
fflib.WriteJsonString(buf, string(v.LastSave))
//.........这里部分代码省略.........