1. 程式人生 > >某些屬性不進行json序列化

某些屬性不進行json序列化

public class FTPServer {
    String guId;
    String  serverName;
    String  ftpServerIP;
    long  ftpServerPort;
    String  ftpServerUserName;
    String  ftpServerPassword;
    int ftpServerStatus; //伺服器狀態,為了頁面顯示方,此處不使用列舉值ServerState

    transient FTPServerSych ftpServerSych;  //封裝CDYRNTCMonConfigInterface,提供併發控制

 ........................

================================

List<FTPServer> ftpServerList = ftpServerInterface.listFTPServer();
        JsonConfig jsonConfig = new JsonConfig();
        jsonConfig.setIgnoreTransientFields(true);//設定為不序列化transient的欄位
        strResult = JSONArray.fromObject(ftpServerList,jsonConfig).toString();