json

package
v0.0.0-...-69d094b Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package json 提供 JSON 相关的一些额外功能

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FieldType

type FieldType string

FieldType 表示字段类型

const (
	Integer FieldType = "integer"
	Int     FieldType = "int"
	String  FieldType = "string"
	Boolean FieldType = "boolean"
	Bool    FieldType = "bool"
	Float   FieldType = "float"
)

type ProtocolAdapter

type ProtocolAdapter interface {
	ConvertJSON(from, to any) error
}

ProtocolAdapter JSON 协议转换器

func NewProtocolAdapterByFieldsConfig

func NewProtocolAdapterByFieldsConfig(mappings []ProtocolAdapterMapping) (ProtocolAdapter, error)

NewProtocolAdapterByFieldsConfig 使用字段映射配置初始化一个解析器

type ProtocolAdapterMapping

type ProtocolAdapterMapping struct {
	From     string    `json:"from"`
	To       string    `json:"to"`
	Required bool      `json:"required,omitempty"`
	Type     FieldType `json:"type,omitempty"`
}

ProtocolAdapterMapping 表示 ProtocolAdapter 的一个字段映射配置

Jump to

Keyboard shortcuts

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