encoding

package
v1.4.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 12, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

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

View Source
const JSON = "json"

JSON is the key for the json encoding

View Source
const NOOP = "no-op"

NOOP is the key for the NoOp encoding

View Source
const SAFE_JSON = "safejson"

SAFE_JSON is the key for the json encoding

View Source
const STRING = "string"

STRING is the key for the string encoding

Variables

This section is empty.

Functions

func JSONCollectionDecoder

func JSONCollectionDecoder(r io.Reader, v *map[string]interface{}) error

JSONCollectionDecoder implements the Decoder interface over a collection

func JSONDecoder

func JSONDecoder(r io.Reader, v *map[string]interface{}) error

JSONDecoder implements the Decoder interface

func NewJSONDecoder

func NewJSONDecoder(isCollection bool) func(io.Reader, *map[string]interface{}) error

NewJSONDecoder return the right JSON decoder

func NewSafeJSONDecoder added in v1.4.3

func NewSafeJSONDecoder(isCollection bool) func(io.Reader, *map[string]interface{}) error

NewJSONDecoder return the right JSON decoder

func NewStringDecoder

func NewStringDecoder(_ bool) func(io.Reader, *map[string]interface{}) error

NewStringDecoder return a String decoder

func NoOpDecoder

func NoOpDecoder(_ io.Reader, _ *map[string]interface{}) error

NoOpDecoder implements the Decoder interface

func Register

func Register(name string, dec func(bool) func(io.Reader, *map[string]interface{}) error) error

Register stores the decoder under a key Deprecated: Register is deprecated

func SafeJSONDecoder added in v1.4.3

func SafeJSONDecoder(r io.Reader, v *map[string]interface{}) error

JSONDecoder implements the Decoder interface

func StringDecoder

func StringDecoder(r io.Reader, v *map[string]interface{}) error

StringDecoder implements the Decoder interface

Types

type Decoder

type Decoder func(io.Reader, *map[string]interface{}) error

A Decoder is a function that reads from the reader and decodes it into an map of interfaces

type DecoderFactory

type DecoderFactory func(bool) func(io.Reader, *map[string]interface{}) error

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

func GetRegister

func GetRegister() *DecoderRegister

GetRegister returns the package register

func (*DecoderRegister) Get

func (r *DecoderRegister) Get(name string) func(bool) func(io.Reader, *map[string]interface{}) error

Get implements the RegisterGetter interface

func (*DecoderRegister) Register

func (r *DecoderRegister) Register(name string, dec func(bool) func(io.Reader, *map[string]interface{}) error) error

Register implements the RegisterSetter interface

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL