已经在Apex中使用Map输出问题了

时间:2016-05-12 10:18:24

标签: salesforce apex

我正在尝试调试Map,我想查看Map中的所有数据。当我使用System.debug()打印地图时,只有第一项显示在日志中,而在第一项后,会显示一条说already output的消息。

是否有使用System.debug()功能在地图中查看数据的解决方法?

2 个答案:

答案 0 :(得分:3)

您可以通过迭代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));
}

enter image description here

答案 1 :(得分:2)

当需要显示的值与之前相同时,显示已输出。