JasperReports 导出到 Json 未正确处理 "null"
JasperReports export to Json not handling "null" correctly
当我在我的报告中使用 Json 元数据并导出到 Json 时,一个文本字段的表达式计算结果为 null
,而不是打印此:{... "field"=null ...}
是打印这个:{... "field"="null" ...}
.
JasperReports 将 null
作为字符串 "null"
处理。如果我将该字段设置为 "blank when null",则会打印:{... "field"="" ...}
.
有什么办法可以避免这种情况吗?
通过将文本字段表达式复制为 net.sf.jasperreports.export.json.data 属性 的表达式,您可以在 JSON 输出中使用空值。如
<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>
当我在我的报告中使用 Json 元数据并导出到 Json 时,一个文本字段的表达式计算结果为 null
,而不是打印此:{... "field"=null ...}
是打印这个:{... "field"="null" ...}
.
JasperReports 将 null
作为字符串 "null"
处理。如果我将该字段设置为 "blank when null",则会打印:{... "field"="" ...}
.
有什么办法可以避免这种情况吗?
通过将文本字段表达式复制为 net.sf.jasperreports.export.json.data 属性 的表达式,您可以在 JSON 输出中使用空值。如
<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>