deserialize

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func File

func File(flag string, result interface{}) (error, string)

Read the contents of a file into the target variable. The type of the target variable should be `io.ReadCloser` and the user-provided value should be a path to a valid file.

func JSON

func JSON(flag string, flagName string, targetDataType string, result interface{}) (error, string)

Deserialize a JSON string value into the target variable. JSON can also be provided through a file if the string starts with '@'. The string is assumed to be valid JSON.

func List

func List(flag string, flagName string, targetDataType string, result interface{}) (err error, msg string)

Deserialize a list of values into the target variable. If the value provided by the user is not already a valid JSON array for the given type, convert it to the proper format before unmarshalling.

func Model

func Model(flag string, flagName string, modelName string, unmarshalFunc core.ModelUnmarshaller, result interface{}) (error, string)

Deserialize a JSON object string value into the target variable, the type of which is a struct representing a model.

func ModelSlice

func ModelSlice(flag string, flagName string, modelName string, unmarshalFunc core.ModelUnmarshaller, result interface{}) (error, string)

Deserialize a JSON array string value into the target variable, the type of which is a struct slice representing a list of models.

func SingleValue

func SingleValue(flag string, flagName string, targetDataType string, result interface{}) (err error, msg string)

Deserialize a single value into the target variable. This is most often used for types like Date and DateTime. If the value provided by the user is not already valid JSON, wrap it in double quotes before unmarshalling.

Types

This section is empty.

Jump to

Keyboard shortcuts

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