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

Already output issue using Map in Apex

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

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

您可以通过迭代地图中的所有值来实现

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));
}

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