json.go 497 B

1234567891011121314151617181920212223242526
  1. package common
  2. import (
  3. jsoniter "git.ikuban.com/server/json"
  4. "google.golang.org/protobuf/types/known/structpb"
  5. )
  6. var json = jsoniter.ConfigCompatibleWithStandardLibrary
  7. func MarshalJSON(v interface{}) []byte {
  8. j, _ := json.Marshal(v)
  9. return j
  10. }
  11. func NewStructValuePB(v interface{}) *structpb.Value {
  12. s := new(structpb.Value)
  13. s.UnmarshalJSON(MarshalJSON(v))
  14. return s
  15. }
  16. func NewStructValuePBByBytes(v []byte) *structpb.Value {
  17. s := new(structpb.Value)
  18. s.UnmarshalJSON(v)
  19. return s
  20. }