本文整理匯總了Golang中github.com/pquerna/ffjson/fflib/v1.EncodingBuffer.WriteString方法的典型用法代碼示例。如果您正苦於以下問題:Golang EncodingBuffer.WriteString方法的具體用法?Golang EncodingBuffer.WriteString怎麽用?Golang EncodingBuffer.WriteString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/pquerna/ffjson/fflib/v1.EncodingBuffer
的用法示例。
在下文中一共展示了EncodingBuffer.WriteString方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: 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
}
示例2: MarshalJSONBuf
func (mj *AgentRender) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
if mj == nil {
buf.WriteString("null")
return nil
}
var err error
var obj []byte
_ = obj
_ = err
buf.WriteString(`{"agent-type":`)
fflib.WriteJsonString(buf, string(mj.Type))
buf.WriteString(`,"position":`)
{
err = mj.Pos2D.MarshalJSONBuf(buf)
if err != nil {
return err
}
}
buf.WriteString(`,"heading":`)
fflib.AppendFloat(buf, float64(mj.Heading), 'g', -1, 64)
/* Struct fall back. type=colour.RGB256 kind=struct */
buf.WriteString(`,"colour":`)
err = buf.Encode(&mj.Colour)
if err != nil {
return err
}
buf.WriteByte('}')
return nil
}
示例3: MarshalJSONBuf
func (mj *Person) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
if mj == nil {
buf.WriteString("null")
return nil
}
var err error
var obj []byte
_ = obj
_ = err
buf.WriteString(`{}`)
return nil
}
示例4: MarshalJSONBuf
func (mj *StatsOutput) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
var err error
var obj []byte
_ = obj
_ = err
buf.WriteString(`{"total":`)
fflib.FormatBits2(buf, uint64(mj.Total), 10, false)
buf.WriteString(`,"verified":`)
fflib.FormatBits2(buf, uint64(mj.Verified), 10, false)
buf.WriteByte('}')
return nil
}
示例5: 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
}
示例6: MarshalJSONBuf
func (mj *EventStream) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
if mj == nil {
buf.WriteString("null")
return nil
}
var err error
var obj []byte
_ = obj
_ = err
buf.WriteString(`{"Err":`)
/* Falling back. type=chan error kind=chan */
err = buf.Encode(mj.Err)
if err != nil {
return err
}
buf.WriteString(`,"Events":`)
/* Falling back. type=chan census.Event kind=chan */
err = buf.Encode(mj.Events)
if err != nil {
return err
}
buf.WriteString(`,"Closed":`)
/* Falling back. type=chan struct {} kind=chan */
err = buf.Encode(mj.Closed)
if err != nil {
return err
}
buf.WriteByte('}')
return nil
}
示例7: MarshalJSONBuf
func (mj *Backend) 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('}')
return nil
}
示例8: MarshalJSONBuf
func (mj *Server) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
if mj == nil {
buf.WriteString("null")
return nil
}
var err error
var obj []byte
_ = obj
_ = err
/* Falling back. type=map[int]*chat.Topic kind=map */
buf.WriteString(`{"users":`)
err = buf.Encode(mj.Topics)
if err != nil {
return err
}
buf.WriteByte('}')
return nil
}
示例9: MarshalJSONBuf
func (mj *State) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
if mj == nil {
buf.WriteString("null")
return nil
}
var err error
var obj []byte
_ = obj
_ = err
buf.WriteString(`{"version":`)
fflib.WriteJsonString(buf, string(mj.Version))
buf.WriteString(`,"id":`)
fflib.WriteJsonString(buf, string(mj.ID))
buf.WriteString(`,"pid":`)
fflib.FormatBits2(buf, uint64(mj.Pid), 10, mj.Pid < 0)
buf.WriteString(`,"bundlePath":`)
fflib.WriteJsonString(buf, string(mj.BundlePath))
buf.WriteByte('}')
return nil
}
示例10: MarshalJSONBuf
func (mj *BroIPFields) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
if mj == nil {
buf.WriteString("null")
return nil
}
var err error
var obj []byte
_ = obj
_ = err
buf.WriteString(`{"id.orig_h":`)
fflib.WriteJsonString(buf, string(mj.ID_orig_h))
buf.WriteString(`,"id.resp_h":`)
fflib.WriteJsonString(buf, string(mj.ID_resp_h))
buf.WriteString(`,"src":`)
fflib.WriteJsonString(buf, string(mj.Src))
buf.WriteString(`,"dst":`)
fflib.WriteJsonString(buf, string(mj.Dst))
buf.WriteByte('}')
return nil
}
示例11: 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
}
示例12: 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
}
示例13: MarshalJSONBuf
func (mj *ServiceDefinition) 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(`,"container_port":`)
fflib.FormatBits2(buf, uint64(mj.ContainerPort), 10, mj.ContainerPort < 0)
if mj.NamePattern != nil {
buf.WriteString(`,"name_pattern":`)
fflib.WriteJsonString(buf, string(*mj.NamePattern))
} else {
buf.WriteString(`,"name_pattern":null`)
}
buf.WriteByte('}')
return nil
}
示例14: MarshalJSONBuf
func (mj *RGB256) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
if mj == nil {
buf.WriteString("null")
return nil
}
var err error
var obj []byte
_ = obj
_ = err
buf.WriteString(`{"red":`)
fflib.FormatBits2(buf, uint64(mj.Red), 10, false)
buf.WriteString(`,"green":`)
fflib.FormatBits2(buf, uint64(mj.Green), 10, false)
buf.WriteString(`,"blue":`)
fflib.FormatBits2(buf, uint64(mj.Blue), 10, false)
buf.WriteByte('}')
return nil
}
示例15: MarshalJSONBuf
func (mj *Router) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
if mj == nil {
buf.WriteString("null")
return nil
}
var err error
var obj []byte
_ = obj
_ = err
buf.WriteString(`{"mac":`)
fflib.WriteJsonString(buf, string(mj.Mac))
buf.WriteString(`,"rssi":`)
fflib.FormatBits2(buf, uint64(mj.Rssi), 10, mj.Rssi < 0)
buf.WriteByte('}')
return nil
}