gorilla/securecookie · securecookie.go
go logo
func (e JSONEncoder) Deserialize(src []byte, dst interface{}) error {
	dec := json.NewDecoder(bytes.NewReader(src))
	if err := dec.Decode(dst); err != nil {
		return cookieError{cause: err, typ: decodeError}
	}
	return nil
}
Similar code snippets
1.
gorilla/securecookie · securecookie.go
Match rating: 68.65% · See similar code snippets
go logo
func (e GobEncoder) Deserialize(src []byte, dst interface{}) error {
	dec := gob.NewDecoder(bytes.NewBuffer(src))
	if err := dec.Decode(dst); err != nil {
		return cookieError{cause: err, typ: decodeError}
	}
	return nil
}
2.
sclasen/swfsm · fsm_models.go
Match rating: 57.8% · See similar code snippets
go logo
func (j JSONStateSerializer) Deserialize(serialized string, state interface{}) error {
	err := json.NewDecoder(strings.NewReader(serialized)).Decode(state)
	return err
}
3.
open-policy-agent/opa · loader.go
Match rating: 56.55% · See similar code snippets
go logo
func loadJSON(path string, bs []byte) (interface{}, error) {
	buf := bytes.NewBuffer(bs)
	decoder := util.NewJSONDecoder(buf)
	var x interface{}
	if err := decoder.Decode(&x); err != nil {
		return nil, errors.Wrap(err, path)
	}
	return x, nil
}
4.
gramework/gramework · context.go
Match rating: 55.79% · See similar code snippets
go logo
func UnJSONBytes(b []byte, v ...interface{}) (interface{}, error) {
	if len(v) == 0 {
		var res interface{}
		err := ffjson.NewDecoder().Decode(b, &res)
		return res, err
	}
	err := ffjson.NewDecoder().Decode(b, &v[0])
	return v[0], err
}
5.
inverse-inc/packetfence · fetch.go
Match rating: 55.05% · See similar code snippets
go logo
func decodeJsonInterface(ctx context.Context, b []byte, o interface{}) {
	decoder := json.NewDecoder(bytes.NewReader(b))
	for {
		if err := decoder.Decode(&o); err == io.EOF {
			break
		} else if err != nil {
			panic(err)
		}
	}
}
6.
CodisLabs/codis · encode.go
Match rating: 54.92% · See similar code snippets
go logo
func jsonDecode(v interface{}, b []byte) error {
	if err := json.Unmarshal(b, v); err != nil {
		return errors.Trace(err)
	}
	return nil
}
7.
lytics/confl · decode.go
Match rating: 54.69% · See similar code snippets
go logo
func (dec *Decoder) Decode(v interface{}) error {
	bs, err := ioutil.ReadAll(dec.reader)
	if err != nil {
		return err
	}
	_, err = Decode(string(bs), v)
	return err
}
8.
minio/minio · utils.go
Match rating: 54.56% · See similar code snippets
go logo
func jsonDecoder(body io.Reader, v interface{}) error {
	d := json.NewDecoder(body)
	return d.Decode(v)
}
9.
hyperhq/hyperd · env.go
Match rating: 54.01% · See similar code snippets
go logo
func (env *Env) Import(src interface{}) (err error) {
	defer func() {
		if err != nil {
			err = fmt.Errorf("ImportEnv: %s", err)
		}
	}()
	var buf bytes.Buffer
	if err := json.NewEncoder(&buf).Encode(src); err != nil {
		return err
	}
	if err := env.Decode(&buf); err != nil {
		return err
	}
	return nil
}
10.
aws/aws-sdk-go · converter.go
Match rating: 53.43% · See similar code snippets
go logo
func convertToTyped(in, out interface{}) error {
	b, err := json.Marshal(in)
	if err != nil {
		return err
	}

	decoder := json.NewDecoder(bytes.NewReader(b))
	return decoder.Decode(&out)
}