json

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: May 5, 2025 License: Apache-2.0 Imports: 2 Imported by: 1

Documentation

Overview

Package json provides a conversion between json and struct.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertFromFile

func ConvertFromFile[T any](fileName string) (T, error)

ConvertFromFile is convert json file to T.

ex) t, err := json.ConvertFromFile[T]("./test.json")

func ConvertFromString

func ConvertFromString[T any](data string) (T, error)

ConvertFromString is convert json string to T.

ex) t, err := json.ConvertFromString[T](data)

func ToString

func ToString(input any) (string, error)

ToString is convert struct to json.

ex) output, err := ToString(testStruct)

func ToStringIndent

func ToStringIndent(input any, prefix string, indent string) (string, error)

ToStringIndent is convert the structto json by apply prefix and indent.

ex) output, err := ToStringIndent(testStruct, "", "\t")

Types

This section is empty.

Jump to

Keyboard shortcuts

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