jsonmap

package
v0.0.0-...-4675295 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: Apache-2.0 Imports: 7 Imported by: 4

README

jsonmap

  • 以通用的json为标准,对map进行约束,这里称为jsonmap。例如key必须为string。
  • 进行约束的目的是为了降低cachez,modifyz的复杂度
  • struct to jsonmap
  • jsonmap to struct

struct支持的tag

package example

type Class struct {
	// 忽视该字段
	IgnoreField interface{} `jsonz:"_"`
	// 别名
	Alias interface{} `jsonz:"--name=alias"`
	// 数组采用map形式保存,用于创建便于继承的json配置文件。
	// 例如,子配置需要修改父配置的数组,只需要通过 {"index":value} 替换父配置的值
	ArrayToMap []interface{} `jsonz:"--tomap"`
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyToAny

func AnyToAny(from interface{}, to interface{}) (err error)

func ConvertBasicToJsonValue

func ConvertBasicToJsonValue(kind basickind.Kind, val interface{}) (r interface{})

ConvertBasicToJsonValue 把目标值,转换成jsonmap定义的类型

func ConvertJsonKeyToReflectKind

func ConvertJsonKeyToReflectKind(kind reflect.Kind, val interface{}) (r interface{})

把目标值,转换成jsonmap定义的类型

func InterfaceToJSONKey

func InterfaceToJSONKey(ival interface{}) string

func InterfaceToJSONValue

func InterfaceToJSONValue(val interface{}) (r interface{})

func JustifyByStruct

func JustifyByStruct(target map[string]interface{}, st interface{}) (result map[string]interface{}, err error)

对 目标[target] 按照 结构[st] 的反射信息,校正字段值,输出到result中

func MapToJsonMap

func MapToJsonMap(from, to map[string]interface{})

func MapToStruct

func MapToStruct(from map[string]interface{}, to interface{}) (err error)

func RemoveNil

func RemoveNil(m map[string]interface{})

func StructToMap

func StructToMap(from interface{}, to map[string]interface{}) (err error)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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