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

json.go 312 B

3 years ago
1234567891011121314151617
  1. package util
  2. import "encoding/json"
  3. func StructToJson(v interface{}) string {
  4. data, err := json.MarshalIndent(v, "", " ")
  5. //data, err := json.Marshal(v)
  6. if err != nil {
  7. panic(err)
  8. }
  9. return string(data)
  10. }
  11. func JsonToStruct(data string, v interface{}) error {
  12. return json.Unmarshal([]byte(data), v)
  13. }

No Description

Contributors (1)