Spring Boot Java替换列表中的空值[已关闭]

myzjeezk  于 2022-11-23  发布在  Spring
关注(0)|答案(1)|浏览(119)

已关闭。此问题需要details or clarity。当前不接受答案。
**想要改进此问题吗?**通过editing this post添加详细信息并阐明问题。

6天前关闭。
Improve this question
我想替换一个包含空值的字段的值。我该怎么做?

List<IncentiveOutputAreRegularResponse> response = new ArrayList<>();

这是我完成的代码

List<IncentiveOutputAreRegularResponse> response = new ArrayList<>();
 for (var item : response) {
    if (Boolean.FALSE.equals(insentiveOutputAreRepository.existsByNikAndBulanAndTahun(
      item.getEmployeeNik(), String.valueOf(item.getMonth()), String.valueOf(item.getYear())))) {
      var result = calculationMapper.mapAre(item);
      insentiveOutputAreRepository.save(result);
    }
  }

谢谢你
我希望包含空值的字段可以更改为默认值

cwxwcias

cwxwcias1#

你问题不是很清楚,但是如果我理解的话,你可以使用“=”作为分隔符,然后检查每个值是否为空,或者你可以用Jackson库(它支持属性的解析,你可以选择你自己的分隔符)来解析你的列表。
https://www.baeldung.com/jackson-deserialize-json-unknown-properties

相关问题