Source File
query.go
Belonging Package
github.com/goccy/go-json
package jsonimport ()type (// FieldQuery you can dynamically filter the fields in the structure by creating a FieldQuery,// adding it to context.Context using SetFieldQueryToContext and then passing it to MarshalContext.// This is a type-safe operation, so it is faster than filtering using map[string]interface{}.FieldQuery = encoder.FieldQueryFieldQueryString = encoder.FieldQueryString)var (// FieldQueryFromContext get current FieldQuery from context.Context.FieldQueryFromContext = encoder.FieldQueryFromContext// SetFieldQueryToContext set current FieldQuery to context.Context.SetFieldQueryToContext = encoder.SetFieldQueryToContext)// BuildFieldQuery builds FieldQuery by fieldName or sub field query.// First, specify the field name that you want to keep in structure type.// If the field you want to keep is a structure type, by creating a sub field query using BuildSubFieldQuery,// you can select the fields you want to keep in the structure.// This description can be written recursively.func ( ...FieldQueryString) (*FieldQuery, error) {, := Marshal()if != nil {return nil,}return FieldQueryString().Build()}// BuildSubFieldQuery builds sub field query.func ( string) *SubFieldQuery {return &SubFieldQuery{name: }}type SubFieldQuery struct {name string}func ( *SubFieldQuery) ( ...FieldQueryString) FieldQueryString {, := Marshal(map[string][]FieldQueryString{.name: })return FieldQueryString()}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |