当我在报告中使用 Json 元数据并导出到 Json(表达式计算结果为 null
的文本字段)时,而不是打印此内容: {... "field"=null 。 ..}
正在打印:{... "field"="null"...}
.
JasperReports 将 null
处理为字符串 "null"
。如果我将字段设置为“空时为空”,则会打印:{... "field"=""...}
。
有没有办法避免这个问题?
最佳答案
通过将文本字段表达式复制为 net.sf.jasperreports.export.json.data 属性的表达式,您可以在 JSON 输出中包含 null 值。如
<textField>
<reportElement ...>
<property name="net.sf.jasperreports.export.json.path" value="FieldThatCanBeNull"/>
<propertyExpression name="net.sf.jasperreports.export.json.data"><![CDATA[$F{FieldThatCanBeNull}]]></propertyExpression>
</reportElement>
<textFieldExpression><![CDATA[$F{FieldThatCanBeNull}]]></textFieldExpression>
</textField>
关于jasper-reports - JasperReports 导出到 Json 无法正确处理 "null",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59176573/