ObjectToJSONByte 将对象转换成JSON字节数组
(obj interface{})
| 22 | |
| 23 | // ObjectToJSONByte 将对象转换成JSON字节数组 |
| 24 | func ObjectToJSONByte(obj interface{}) []byte { |
| 25 | b, err := json.Marshal(obj) |
| 26 | if err != nil { |
| 27 | return []byte("{}") |
| 28 | } |
| 29 | return b |
| 30 | } |
| 31 | |
| 32 | // ObjectToJSONString 将对象转换成JSON字符串 |
| 33 | func ObjectToJSONString(obj interface{}) string { |
no outgoing calls
no test coverage detected