-
Notifications
You must be signed in to change notification settings - Fork 12
/
jsonpb.option.go
33 lines (28 loc) · 1017 Bytes
/
jsonpb.option.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright 2020 The searKing Author. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package runtime
// WithEmitAsInts specifies whether to render enum values as integers, as opposed to string values.
func WithEmitAsInts(enumsAsInts bool) JSONPbOption {
return JSONPbOptionFunc(func(pb *JSONPb) {
pb.JSONPb.EnumsAsInts = enumsAsInts
})
}
// WithEmitDefaults specifies whether to render fields with zero values.
func WithEmitDefaults(emitDefaults bool) JSONPbOption {
return JSONPbOptionFunc(func(pb *JSONPb) {
pb.JSONPb.EmitDefaults = emitDefaults
})
}
// WithIndent controls whether the output is compact or not.
func WithIndent(indent string) JSONPbOption {
return JSONPbOptionFunc(func(pb *JSONPb) {
pb.JSONPb.Indent = indent
})
}
// Whether to use the original (.proto) name for fields.
func WithOrigName(origName bool) JSONPbOption {
return JSONPbOptionFunc(func(pb *JSONPb) {
pb.JSONPb.OrigName = origName
})
}