encoding

package
v0.0.0-...-7f749bc Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2017 License: Apache-2.0 Imports: 2 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)

Index

Constants

View Source
const JSON = "json"

JSON is the key for the json 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 Register

func Register(name string, dec DecoderFactory) error

Register registers the decoder factory with the given name

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

func NewJSONDecoder

func NewJSONDecoder(isCollection bool) Decoder

NewJSONDecoder return the right JSON decoder

type DecoderFactory

type DecoderFactory func(bool) Decoder

A DecoderFactory is a function that returns CollectionDecoder or an EntityDecoder

func Get

func Get(name string) DecoderFactory

Get returns (from the register) the decoder factory by name. If there is no factory with the received name it returns the JSON decoder factory

Jump to

Keyboard shortcuts

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