...
1 package json
2
3 import (
4 "github.com/goccy/go-json/internal/encoder"
5 )
6
7 type (
8
9
10
11 FieldQuery = encoder.FieldQuery
12 FieldQueryString = encoder.FieldQueryString
13 )
14
15 var (
16
17 FieldQueryFromContext = encoder.FieldQueryFromContext
18
19 SetFieldQueryToContext = encoder.SetFieldQueryToContext
20 )
21
22
23
24
25
26
27 func BuildFieldQuery(fields ...FieldQueryString) (*FieldQuery, error) {
28 query, err := Marshal(fields)
29 if err != nil {
30 return nil, err
31 }
32 return FieldQueryString(query).Build()
33 }
34
35
36 func BuildSubFieldQuery(name string) *SubFieldQuery {
37 return &SubFieldQuery{name: name}
38 }
39
40 type SubFieldQuery struct {
41 name string
42 }
43
44 func (q *SubFieldQuery) Fields(fields ...FieldQueryString) FieldQueryString {
45 query, _ := Marshal(map[string][]FieldQueryString{q.name: fields})
46 return FieldQueryString(query)
47 }
48
View as plain text