json

package module
v0.0.0-...-71a5000 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2016 License: MIT Imports: 5 Imported by: 0

README

http-json

JSON helpers to read (both filtered and unfiltered) and write JSON request bodies.

Build Status GoDoc

Example
json.Read(r, &user)
json.ReadFiltered(r, &user, []string{"name"})
json.Write(rw, &user)

License

MIT

Documentation

Overview

Package json provides helper methods to read (both filtered and unfiltered) and write JSON request bodies.

json.Read(r, &user)
json.ReadFiltered(r, &user, []string{"name"})
json.Write(rw, &user)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Read

func Read(r *http.Request, v interface{}) error

Read reads the JSON body of the given context and decodes it into the provided data structure.

func ReadFiltered

func ReadFiltered(req *http.Request, dst interface{}, whitelist []string) error

Read allows to read a JSON request body into a struct while filtering the read JSON properties by the provided whitelist.

func Write

func Write(rw http.ResponseWriter, data interface{})

Write marshals the given data and writes it to the provided context.

Types

This section is empty.

Jump to

Keyboard shortcuts

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