jsonconv

package
v0.0.0-...-79697a8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 13, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Camel = 0 //驼峰
	Case  = 1 //下划线
)

Variables

This section is empty.

Functions

func Camel2Case

func Camel2Case(name string) string

驼峰式写法转为下划线写法

func Case2Camel

func Case2Camel(s string) string

*

  • 蛇形转驼峰
  • @description xx_yy to XxYx xx_y_y to XxYY
  • @date 2020/7/30
  • @param s要转换的字符串
  • @return string *

func DeepCopyByGob

func DeepCopyByGob(src, dst interface{}) error

*

  • @Description: 利用gob进行深拷贝

func DeepCopyByReflect

func DeepCopyByReflect(src, dst interface{}) (err error)

src->dst 参数传递时,第src使用指针还是实例请自行斟酌,dst必须是指针,涉及的字段必须是对外的

func DeepCopyByjsoniter

func DeepCopyByjsoniter(src, dst any) error

*

  • @Description: 利用jsoniter进行深拷贝 obj,&objTo

func DeepCopyByjsoniterCamelOrCase

func DeepCopyByjsoniterCamelOrCase(src, dst any, useCamel bool) error

驼峰式jsoniter

func JsonToObject

func JsonToObject(jsonStr string, obj any) error

调用 JsonToObject(jsonStr , &obj)

func Lcfirst

func Lcfirst(str string) string

首字母小写

func ObjectToJson

func ObjectToJson(data any) string

func Ucfirst

func Ucfirst(str string) string

首字母大写

Types

type Buffer

type Buffer struct {
	*bytes.Buffer
}

内嵌bytes.Buffer,支持连写

func NewBuffer

func NewBuffer() *Buffer

func (*Buffer) Append

func (b *Buffer) Append(i interface{}) *Buffer

type JsonCamelCase

type JsonCamelCase struct {
	Value interface{}
}

************************************** 驼峰json **************************************

func (JsonCamelCase) MarshalJSON

func (c JsonCamelCase) MarshalJSON() ([]byte, error)

type JsonSnakeCase

type JsonSnakeCase struct {
	Value interface{}
}

https://www.cnblogs.com/chenqionghe/p/13067596.html ************************************** 下划线json **************************************

func (JsonSnakeCase) MarshalJSON

func (c JsonSnakeCase) MarshalJSON() ([]byte, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL