qrz/vendor/xorm.io/xorm/internal/json/json.go

32 lines
796 B
Go
Raw Normal View History

2020-07-19 19:32:22 +02:00
// Copyright 2019 The Xorm Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package json
import "encoding/json"
2021-08-30 19:45:06 +02:00
// Interface represents an interface to handle json data
type Interface interface {
2020-07-19 19:32:22 +02:00
Marshal(v interface{}) ([]byte, error)
Unmarshal(data []byte, v interface{}) error
}
var (
// DefaultJSONHandler default json handler
2021-08-30 19:45:06 +02:00
DefaultJSONHandler Interface = StdJSON{}
2020-07-19 19:32:22 +02:00
)
// StdJSON implements JSONInterface via encoding/json
type StdJSON struct{}
// Marshal implements JSONInterface
func (StdJSON) Marshal(v interface{}) ([]byte, error) {
return json.Marshal(v)
}
// Unmarshal implements JSONInterface
func (StdJSON) Unmarshal(data []byte, v interface{}) error {
return json.Unmarshal(data, v)
}