json2struct

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2021 License: MIT Imports: 7 Imported by: 0

README

json2struct

Unmarshal json to struct, returning affected fields

Build Status Coverage Status Go Report Card Documentation

Install

$ go get github.com/lovego/json2struct

Documentation

https://godoc.org/github.com/lovego/json2struct

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