当前位置: 首页>>代码示例>>Golang>>正文


Golang v1.WriteJsonString函数代码示例

本文整理汇总了Golang中github.com/pquerna/ffjson/fflib/v1.WriteJsonString函数的典型用法代码示例。如果您正苦于以下问题:Golang WriteJsonString函数的具体用法?Golang WriteJsonString怎么用?Golang WriteJsonString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了WriteJsonString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: MarshalJSONBuf

func (mj *User) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
	if mj == nil {
		buf.WriteString("null")
		return nil
	}
	var err error
	var obj []byte
	_ = obj
	_ = err
	buf.WriteString(`{"name":`)
	fflib.WriteJsonString(buf, string(mj.Name))
	buf.WriteString(`,"color":`)
	fflib.WriteJsonString(buf, string(mj.Color))
	if mj.LoggedIn {
		buf.WriteString(`,"logged-in":true`)
	} else {
		buf.WriteString(`,"logged-in":false`)
	}
	/* Falling back. type=map[int]chat.voteOption kind=map */
	buf.WriteString(`,"voteMask":`)
	err = buf.Encode(mj.Votes)
	if err != nil {
		return err
	}
	buf.WriteByte('}')
	return nil
}
开发者ID:strawmang,项目名称:strawmang,代码行数:27,代码来源:ffjson_chat.go

示例2: 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
}
开发者ID:wheelcomplex,项目名称:geoip-service,代码行数:27,代码来源:reader_ffjson.go

示例3: MarshalJSONBuf

func (mj *MtBroadCastMessage) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
	if mj == nil {
		buf.WriteString("null")
		return nil
	}
	var err error
	var obj []byte
	_ = obj
	_ = err
	buf.WriteString(`{"topics":`)
	if mj.Clients != nil {
		buf.WriteString(`[`)
		for i, v := range mj.Clients {
			if i != 0 {
				buf.WriteString(`,`)
			}
			fflib.WriteJsonString(buf, string(v))
		}
		buf.WriteString(`]`)
	} else {
		buf.WriteString(`null`)
	}
	buf.WriteString(`,"payload":`)
	fflib.WriteJsonString(buf, string(mj.Payload))
	buf.WriteByte('}')
	return nil
}
开发者ID:nagae-memooff,项目名称:surgemq,代码行数:27,代码来源:process_ffjson.go

示例4: 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
}
开发者ID:raiqub,项目名称:oauth,代码行数:26,代码来源:errors_ffjson.go

示例5: 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(`{"Payload":`)

	{

		err = mj.Payload.MarshalJSONBuf(buf)
		if err != nil {
			return err
		}

	}
	buf.WriteString(`,"service":`)
	fflib.WriteJsonString(buf, string(mj.Service))
	buf.WriteString(`,"type":`)
	fflib.WriteJsonString(buf, string(mj.Type))
	buf.WriteByte('}')
	return nil
}
开发者ID:THUNDERGROOVE,项目名称:census,代码行数:26,代码来源:event_stream_ffjson.go

示例6: 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
}
开发者ID:postfix,项目名称:bangarang,代码行数:29,代码来源:event_ffjson.go

示例7: 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
}
开发者ID:xinhp,项目名称:libs,代码行数:35,代码来源:logger_ffjson.go

示例8: 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
}
开发者ID:wheelcomplex,项目名称:oui,代码行数:58,代码来源:entry_ffjson.go

示例9: MarshalJSONBuf

func (mj *TaskEvent) 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(`,"hostname":`)
	fflib.WriteJsonString(buf, string(mj.Hostname))
	buf.WriteString(`,"timestamp":`)
	fflib.AppendFloat(buf, float64(mj.Timestamp), 'g', -1, 32)
	buf.WriteString(`,"pid":`)
	fflib.FormatBits2(buf, uint64(mj.PID), 10, mj.PID < 0)
	buf.WriteString(`,"clock":`)
	fflib.FormatBits2(buf, uint64(mj.Clock), 10, mj.Clock < 0)
	buf.WriteString(`,"utcoffset":`)
	fflib.FormatBits2(buf, uint64(mj.UTCOffset), 10, mj.UTCOffset < 0)
	buf.WriteString(`,"uuid":`)
	fflib.WriteJsonString(buf, string(mj.UUID))
	buf.WriteString(`,"name":`)
	fflib.WriteJsonString(buf, string(mj.Name))
	buf.WriteString(`,"args":`)
	fflib.WriteJsonString(buf, string(mj.Args))
	buf.WriteString(`,"kwargs":`)
	fflib.WriteJsonString(buf, string(mj.Kwargs))
	buf.WriteString(`,"result":`)
	fflib.WriteJsonString(buf, string(mj.Result))
	buf.WriteString(`,"runtime":`)
	fflib.AppendFloat(buf, float64(mj.Runtime), 'g', -1, 32)
	buf.WriteString(`,"retries":`)
	fflib.FormatBits2(buf, uint64(mj.Retries), 10, mj.Retries < 0)
	buf.WriteString(`,"eta":`)
	fflib.FormatBits2(buf, uint64(mj.ETA), 10, mj.ETA < 0)
	buf.WriteString(`,"exception":`)
	fflib.WriteJsonString(buf, string(mj.Exception))
	buf.WriteString(`,"traceback":`)
	fflib.WriteJsonString(buf, string(mj.Traceback))
	if mj.Terminated {
		buf.WriteString(`,"terminated":true`)
	} else {
		buf.WriteString(`,"terminated":false`)
	}
	buf.WriteString(`,"signum":`)
	/* Interface types must use runtime reflection. type=interface {} kind=interface */
	err = buf.Encode(mj.Signum)
	if err != nil {
		return err
	}
	if mj.Expired {
		buf.WriteString(`,"expired":true`)
	} else {
		buf.WriteString(`,"expired":false`)
	}
	buf.WriteByte('}')
	return nil
}
开发者ID:tugouer,项目名称:celeriac.v1,代码行数:60,代码来源:task_event_ffjson.go

示例10: MarshalJSONBuf

func (mj *Outfit) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
	if mj == nil {
		buf.WriteString("null")
		return nil
	}
	var err error
	var obj []byte
	_ = obj
	_ = err
	buf.WriteString(`{"outfit_id":`)
	fflib.WriteJsonString(buf, string(mj.ID))
	buf.WriteString(`,"name":`)
	fflib.WriteJsonString(buf, string(mj.Name))
	buf.WriteString(`,"name_lower":`)
	fflib.WriteJsonString(buf, string(mj.NameLower))
	buf.WriteString(`,"alias":`)
	fflib.WriteJsonString(buf, string(mj.Alias))
	buf.WriteString(`,"alias_lower":`)
	fflib.WriteJsonString(buf, string(mj.AliasLower))
	buf.WriteString(`,"time_created":`)
	fflib.WriteJsonString(buf, string(mj.TimeCreated))
	buf.WriteString(`,"leader_character_id":`)
	fflib.WriteJsonString(buf, string(mj.LeaderCharID))
	buf.WriteString(`,"member_count":`)
	fflib.WriteJsonString(buf, string(mj.MemberCount))
	buf.WriteByte('}')
	return nil
}
开发者ID:THUNDERGROOVE,项目名称:census,代码行数:28,代码来源:outfit_ffjson.go

示例11: 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
}
开发者ID:postfix,项目名称:bangarang,代码行数:58,代码来源:incident_ffjson.go

示例12: MarshalJSONBuf

func (mj *LogoInfo) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
	if mj == nil {
		buf.WriteString("null")
		return nil
	}
	var err error
	var obj []byte
	_ = obj
	_ = err
	buf.WriteString(`{"Path":`)
	fflib.WriteJsonString(buf, string(mj.Path))
	buf.WriteString(`,"Name":`)
	fflib.WriteJsonString(buf, string(mj.Name))
	buf.WriteByte('}')
	return nil
}
开发者ID:chenbk85,项目名称:nephele,代码行数:16,代码来源:logoinfo_ffjson.go

示例13: 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
}
开发者ID:benjamin-rood,项目名称:gobr,代码行数:25,代码来源:json-types_ffjson.go

示例14: 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
}
开发者ID:benjamin-rood,项目名称:abm-cp,代码行数:32,代码来源:render_ffjson.go

示例15: 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
}
开发者ID:wheelcomplex,项目名称:geoip-service,代码行数:29,代码来源:geoip_ffjson.go


注:本文中的github.com/pquerna/ffjson/fflib/v1.WriteJsonString函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。