json2struct

package
v0.0.0-...-d31700d Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2022 License: MIT Imports: 7 Imported by: 0

README

json2struct

Unmarshal json to struct, returning affected fields

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Affected

func Affected(data []byte, p interface{}) ([]string, error)

Affected return the fields will be affected of a struct, if the data is decoded into the the struct.

func GetFields

func GetFields(p interface{}) ([]fieldT, error)

func Unmarshal

func Unmarshal(data []byte, p interface{}) ([]string, error)

Unmarshal decode data into a struct, and return the affected fields of the struct.

Example
var v struct {
	A, B, C int64
}
fields, err := Unmarshal([]byte(`{"a": 1, "b": 0}`), &v)

fmt.Printf("%+v\n", v)
fmt.Println(fields, err)
Output:

{A:1 B:0 C:0}
[A B] <nil>

Types

This section is empty.

Jump to

Keyboard shortcuts

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