ToStringUtils.java 989 Bytes
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;
    }



}