jsonconv

package
v0.0.0-...-d2c9018 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: Apache-2.0 Imports: 7 Imported by: 9

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func AnyToAny

func AnyToAny(data any, obj any) (err error)

默认json

func AnyToAnyNE

func AnyToAnyNE[T any](data any) (out *T)

func AnyToJson

func AnyToJson(data any) (string, error)

func AnyToJsonCamel

func AnyToJsonCamel(data any) string

转首字母驼峰json

func AnyToJsonIndent

func AnyToJsonIndent(data any) string

转换行结构json

func AnyToJsonNE

func AnyToJsonNE(data any) string

func AnyToJsonSnake

func AnyToJsonSnake(data any) string

************************************** 其他方法 ************************************** 转下划线json

func AnyToMap

func AnyToMap(obj interface{}) (map[string]interface{}, error)

func AnyToMapNE

func AnyToMapNE(obj interface{}) map[string]interface{}

func Case2Camel

func Case2Camel(xx_y_y string) string

*

  • 下划线转驼峰
  • @description xx_yy to XxYx xx_y_y to XxYY XxYY to XxYY
  • @date 2023/2/15
  • @param xx_y_y
  • @return XxYY *

func Case2Snake

func Case2Snake(XxYY string) string

*

  • 驼峰式写法转为下划线写法
  • @description XxYx->xx_yy XxYY->xx_yy EncodeURL->url TagDTOList->tag_dto_list *

func ExtractLetters

func ExtractLetters(s string) string

获取字符串中的英文

func FirstLower

func FirstLower(s string) string

首字母小写

func FirstUpper

func FirstUpper(s string) string

首字母大写

func JsonToAny

func JsonToAny(js string, obj any) error

调用 JsonToAny(jsonStr , &obj)

func JsonToAnyIgnoreCase

func JsonToAnyIgnoreCase(data string, obj interface{}) error

json解析忽略大小写

func JsonToAnyNE

func JsonToAnyNE[T any](js string) (out T)

不支持根据返回值类型推断

func JsonToMap

func JsonToMap(data []byte) (map[string]interface{}, error)

func JsonToMapNE

func JsonToMapNE(data []byte) map[string]interface{}

Types

type JsonCamelCase

type JsonCamelCase struct {
	Value interface{}
}

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

func (JsonCamelCase) MarshalJSON

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

转换为json,key全部变为下划线

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)

转换为json,key全部变为驼峰

Jump to

Keyboard shortcuts

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