Debian Codegraph @

decoder.go

raw
1 // Copyright 2012-present Oliver Eilhard. All rights reserved.
2 // Use of this source code is governed by a MIT-license.
3 // See http://olivere.mit-license.org/license.txt for details.
4
5 package elastic
6
7 import (
8 "encoding/json"
9 )
10
11 // Decoder is used to decode responses from Elasticsearch.
12 // Users of elastic can implement their own marshaler for advanced purposes
13 // and set them per Client (see SetDecoder). If none is specified,
14 // DefaultDecoder is used.
15 type Decoder interface {
16 Decode(data []byte, v interface{}) error
17 }
18
19 // DefaultDecoder uses json.Unmarshal from the Go standard library
20 // to decode JSON data.
21 type DefaultDecoder struct{}
22
23 // Decode decodes with json.Unmarshal from the Go standard library.
24 func (u *DefaultDecoder) Decode(data []byte, v interface{}) error {
25 return json.Unmarshal(data, v)
26 }