Categorygithub.com/davidcai1993/json-mask-go
modulepackage
0.2.2
Repository: https://github.com/davidcai1993/json-mask-go.git
Documentation: pkg.go.dev

# README

json-mask-go

Build Status Coverage Status

JSON mask for Go

Warning: for now this package only support filtering top level properties.

Installation

go get -u github.com/DavidCai1993/json-mask-go

Documentation

API documentation can be found here: https://godoc.org/github.com/DavidCai1993/json-mask-go

Usage

type ExampleStruct struct {
  A string             `json:"a"`
  B int                `json:"b"`
  C map[string]float32 `json:"c"`
}

result, _ := jsonmask.Mask(ExampleStruct{
  A: "aaa",
  B: 234,
  C: map[string]float32{"c1": 12, "c2": 33},
}, "a,c")

j, _ := json.Marshal(result)

fmt.Println("json output: ", string(j))
// json output:  {"a":"aaa","c":{"c1":12,"c2":33}}

# Functions

Mask selects the specific parts of an object, according to the "mask".

# Variables

Errors exposed.