本站源代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
808B

  1. // Copyright 2019 The Xorm Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package xorm
  5. import "encoding/json"
  6. // JSONInterface represents an interface to handle json data
  7. type JSONInterface interface {
  8. Marshal(v interface{}) ([]byte, error)
  9. Unmarshal(data []byte, v interface{}) error
  10. }
  11. var (
  12. // DefaultJSONHandler default json handler
  13. DefaultJSONHandler JSONInterface = StdJSON{}
  14. )
  15. // StdJSON implements JSONInterface via encoding/json
  16. type StdJSON struct{}
  17. // Marshal implements JSONInterface
  18. func (StdJSON) Marshal(v interface{}) ([]byte, error) {
  19. return json.Marshal(v)
  20. }
  21. // Unmarshal implements JSONInterface
  22. func (StdJSON) Unmarshal(data []byte, v interface{}) error {
  23. return json.Unmarshal(data, v)
  24. }
上海开阖软件有限公司 沪ICP备12045867号-1