Documentation ¶
Overview ¶
Package encoding provides Decoding implementations.
Decode decodes HTTP responses:
resp, _ := http.Get("http://api.example.com/") ... var data map[string]interface{} err := JSONDecoder(resp.Body, &data)
SPDX-License-Identifier: Apache-2.0
SPDX-License-Identifier: Apache-2.0
SPDX-License-Identifier: Apache-2.0
SPDX-License-Identifier: Apache-2.0
Index ¶
- Constants
- func JSONCollectionDecoder(r io.Reader, v *map[string]interface{}) error
- func JSONDecoder(r io.Reader, v *map[string]interface{}) error
- func NewJSONDecoder(isCollection bool) func(io.Reader, *map[string]interface{}) error
- func NewSafeJSONDecoder(isCollection bool) func(io.Reader, *map[string]interface{}) error
- func NewStringDecoder(_ bool) func(io.Reader, *map[string]interface{}) error
- func NoOpDecoder(_ io.Reader, _ *map[string]interface{}) error
- func Register(name string, dec func(bool) func(io.Reader, *map[string]interface{}) error) error
- func SafeJSONDecoder(r io.Reader, v *map[string]interface{}) error
- func StringDecoder(r io.Reader, v *map[string]interface{}) error
- type Decoder
- type DecoderFactory
- type DecoderRegister
Constants ¶
const JSON = "json"
JSON is the key for the json encoding
const NOOP = "no-op"
NOOP is the key for the NoOp encoding
const SAFE_JSON = "safejson"
SAFE_JSON is the key for the json encoding
const STRING = "string"
STRING is the key for the string encoding
Variables ¶
This section is empty.
Functions ¶
func JSONCollectionDecoder ¶
JSONCollectionDecoder implements the Decoder interface over a collection
func JSONDecoder ¶
JSONDecoder implements the Decoder interface
func NewJSONDecoder ¶
NewJSONDecoder return the right JSON decoder
func NewSafeJSONDecoder ¶
NewJSONDecoder return the right JSON decoder
func NewStringDecoder ¶
NewStringDecoder return a String decoder
func NoOpDecoder ¶
NoOpDecoder implements the Decoder interface
func SafeJSONDecoder ¶
JSONDecoder implements the Decoder interface
Types ¶
type Decoder ¶
A Decoder is a function that reads from the reader and decodes it into an map of interfaces
type DecoderFactory ¶
A DecoderFactory is a function that returns CollectionDecoder or an EntityDecoder
func Get ¶
func Get(name string) DecoderFactory
Get looks up for the requested decoder by a key Deprecated: Get is deprecated
type DecoderRegister ¶
type DecoderRegister struct {
// contains filtered or unexported fields
}
DecoderRegister is the struct responsible of registering the decoder factories