@@ -109,25 +109,23 @@ func (e JSONSelectEncoder) EncodeEntry(entry zapcore.Entry, fields []zapcore.Fie
109
109
return buf , err
110
110
}
111
111
112
- // fixme > indexing array of strings not working at the moment
113
- // fixme > this is a bug in jsonparser (see https://github.com/buger/jsonparser/issues/232)
114
- // todo > workaround by iterating on paths and calling jsonparser.Get()
115
112
res := []byte {'{' , '}' }
116
- jsonparser .EachKey (
117
- buf .Bytes (),
118
- func (idx int , val []byte , typ jsonparser.ValueType , err error ) {
119
- // todo > handle error
120
- switch typ {
121
- case jsonparser .NotExist :
122
- // path not found, skip
123
- case jsonparser .String :
124
- res , _ = jsonparser .Set (res , append (append ([]byte {'"' }, val ... ), '"' ), e .setters [idx ]... )
125
- default :
126
- res , _ = jsonparser .Set (res , val , e .setters [idx ]... )
127
- }
128
- },
129
- e .getters ... ,
130
- )
113
+ // Temporary workaround the bug https://github.com/buger/jsonparser/issues/232
114
+ // todo > switch back to EachKey (see git history) for perf reasons when fixed
115
+ for idx , paths := range e .getters {
116
+ val , typ , _ , err := jsonparser .Get (buf .Bytes (), paths ... )
117
+ if err != nil {
118
+ return nil , err
119
+ }
120
+ switch typ {
121
+ case jsonparser .NotExist :
122
+ // path not found, skip
123
+ case jsonparser .String :
124
+ res , _ = jsonparser .Set (res , append (append ([]byte {'"' }, val ... ), '"' ), e .setters [idx ]... )
125
+ default :
126
+ res , _ = jsonparser .Set (res , val , e .setters [idx ]... )
127
+ }
128
+ }
131
129
132
130
// Reset the buffer to output our own content
133
131
buf .Reset ()
0 commit comments