func coerce(i interface{}) (interface{}, error) {
	if i == nil {
		return i, nil
	}
	switch i.(type) {
	case map[string]interface{}:
		return i, nil
	case []interface{}:
		return i, nil
	}
	b, err := json.Marshal(i)
	if err != nil {
		return nil, err
	}
	var v interface{}
	return v, json.Unmarshal(b, &v)
}
coerces the original interface into a vanilla interface.
package jsonmp
import (
	"encoding/json"
	"io"
)
func Patch(a, b []byte) ([]byte, error) {
	a = append(a, 0)
	copy(a[1:], a[0:])
	a[0] = '['
	a = append(a, ',')
	a = append(a, b...)
	a = append(a, ']')
	var i []interface{}
	if err := json.Unmarshal(a, &i); err != nil {
		return nil, err
	}
	return json.Marshal(patch(i[0], i[1]))
}
func PatchValue(a, b, dst interface{}) error {
	var err error
	if a, err = coerce(a); err != nil {
		return err
	}
	if b, err = coerce(b); err != nil {
		return err
	}
	return marshalValue(a, b, dst)
}
func PatchValueWithBytes(a interface{}, c []byte, dst interface{}) error {
	var err error
	if a, err = coerce(a); err != nil {
		return err
	}
	var b interface{}
	if err = json.Unmarshal(c, &b); err != nil {
		return err
	}
	return marshalValue(a, b, dst)
}
func PatchValueWithReader(a interface{}, r io.Reader, dst interface{}) error {
	var err error
	if a, err = coerce(a); err != nil {
		return err
	}
	var b interface{}
	if err = json.NewDecoder(r).Decode(&b); err != nil {
		return err
	}
	return marshalValue(a, b, dst)
}
func marshalValue(a, b, dst interface{}) error {
	c, err := json.Marshal(patch(a, b))
	if err != nil {
		return err
	}
	return json.Unmarshal(c, &dst)
}
type Patcher struct {
	r io.Reader
	w io.Writer
}
func NewPatcher(r io.Reader, w io.Writer) *Patcher {
	return &Patcher{r, w}
}
func (p *Patcher) Patch(c []byte) error {
	b, err := read(p.r)
	if err != nil {
		return err
	}
	var a interface{}
	if err := json.Unmarshal(c, &a); err != nil {
		return err
	}
	return p.write(a, b)
}
func (p *Patcher) PatchValue(a interface{}) error {
	var err error
	if a, err = coerce(a); err != nil {
		return err
	}
	b, err := read(p.r)
	if err != nil {
		return err
	}
	return p.write(a, b)
}
func read(r io.Reader) (interface{}, error) {
	var i interface{}
	err := json.NewDecoder(r).Decode(&i)
	return i, err
}
func (p *Patcher) write(a, b interface{}) error {
	return json.NewEncoder(p.w).Encode(patch(a, b))
}