json

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2025 License: GPL-3.0 Imports: 4 Imported by: 3

Documentation

Index

Constants

View Source
const (
	JSONTag       = "json"
	JSONOmitempty = "omitempty"
)
View Source
const (
	ErrEmptyJSONTag    = "empty json tag for field: %s"
	ErrJSONTagNotFound = "json tag not found for field: %s"
)

Variables

This section is empty.

Functions

func GetJSONTag

func GetJSONTag(structField *reflect.StructField, fieldName string) (string, error)

GetJSONTag returns the JSON tag for a given struct field

Parameters:

- structField: The struct field - fieldName: The name of the struct field

Returns:

- string: JSON tag - error: error if the field does not exist

func GetJSONTagName

func GetJSONTagName(jsonTag, fieldName string) (string, error)

GetJSONTagName returns the JSON tag name for a given struct field name

Parameters:

- jsonTag: The JSON tag of the struct field - fieldName: The name of the struct field

Returns:

- string: JSON tag name - error: error if the JSON tag is empty

func IsJSONFieldOptional added in v0.2.2

func IsJSONFieldOptional(jsonTag string) bool

IsJSONFieldOptional returns true if the JSON field is optional

Parameters:

  • jsonTag: The JSON tag of the struct field

Returns:

  • bool: true if the JSON field is optional

Types

This section is empty.

Jump to

Keyboard shortcuts

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