0
我正在嘗試調試Map,並且想要查看Map中的所有數據。當我使用System.debug()
打印地圖時,只有第一個項目顯示在日誌中,第一個項目之後有消息說already output
。已在Apex中使用Map輸出問題
是否有任何解決方法可以使用System.debug()
功能查看Map中的數據?
我正在嘗試調試Map,並且想要查看Map中的所有數據。當我使用System.debug()
打印地圖時,只有第一個項目顯示在日誌中,第一個項目之後有消息說already output
。已在Apex中使用Map輸出問題
是否有任何解決方法可以使用System.debug()
功能查看Map中的數據?
您可以通過地圖迭代所有值做
Map<String, String> mapToPrint = new Map<String, String>();
mapToPrint.put('key1', 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry');
mapToPrint.put('key2', 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry');
mapToPrint.put('key3', 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry');
mapToPrint.put('key4', 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry');
mapToPrint.put('key5', 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry');
mapToPrint.put('key6', 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry');
mapToPrint.put('key7', 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry');
mapToPrint.put('key8', 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry');
mapToPrint.put('key9', 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry');
mapToPrint.put('key10', 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry');
mapToPrint.put('key11', 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry');
Boolean contains = mapToPrint.containsKey('Blue');
System.assertEquals(true, contains);
for (String key: mapToPrint.keySet()) {
System.debug(LoggingLevel.DEBUG, 'key: ' + key + ' --> value: ' + mapToPrint.get(key));
}
時需要顯示的值是一樣的前面已經輸出顯示。