ToStringUtils.java
989 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package com.cnlive.im.util;
import com.cnlive.im.mode.CNMessageModole;
/**
* @author 陈硕
* @time 2017/3/28 10:20
* @desc ${TODD}
*/
public class ToStringUtils {
public static String objToJsonString(CNMessageModole cnMessageModole) {
// 初始化返回值
String json = "str_empty";
if (cnMessageModole == null) {
return json;
}
StringBuilder buff = new StringBuilder();
buff.append("{");
buff.append("message");
buff.append(":");
buff.append("\"");
buff.append(cnMessageModole.getMessage() == null ? "" : cnMessageModole.getMessage());
buff.append("\"");
buff.append(",");
buff.append("type");
buff.append(":");
buff.append("\"");
buff.append(cnMessageModole.getType() == null ? "" : cnMessageModole.getType());
buff.append("\"");
buff.append("}");
json = buff.toString();
return json;
}
}