hentai.exe Posted July 17, 2021 Share Posted July 17, 2021 Hello! There are many questions about json arrays here, but I didn't find any answer working for me. Please, help.I have a simple json:{ "header" : "some header", "footer" : "some footer", "strings": [ "foo", "bar", "baz" ]}[/code]and a simple report:<?xml version="1.0" encoding="UTF-8"?><!-- Created with Jaspersoft Studio version 6.17.0.final using JasperReports Library version 6.17.0-6d93193241dd8cc42629e188b94f9e0bc5722efd --><jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="sample" pageWidth="595" pageHeight="300" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="6c570f43-054a-44a9-a9b1-ba4cf2cdcf86"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="json-sample"/> <subDataset name="ListDataSet" uuid="fb812d2a-cb63-473c-b7d3-149977476dd0"> <field name="val" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="strings.*"/> </field> </subDataset> <queryString language="jsonql"> <![CDATA[]]> </queryString> <field name="header" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="header"/> <fieldDescription><![CDATA[header]]></fieldDescription> </field> <field name="footer" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="footer"/> <fieldDescription><![CDATA[footer]]></fieldDescription> </field> <field name="strings" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="strings"/> <fieldDescription><![CDATA[strings]]></fieldDescription> </field> <background> <band splitType="Stretch"/> </background> <pageHeader> <band height="30" splitType="Stretch"> <textField> <reportElement x="0" y="0" width="100" height="30" uuid="d98a55eb-ebbd-4cdd-8fa2-ae052b124aaa"/> <textFieldExpression><![CDATA[$F{header}]]></textFieldExpression> </textField> </band> </pageHeader> <detail> <band height="30" splitType="Stretch"> <componentElement> <reportElement x="0" y="0" width="450" height="30" uuid="887dc258-2eac-4492-ae69-f9b2ffd1faee"> <property name="com.jaspersoft.studio.unit.CONTENTS.width" value="px"/> </reportElement> <jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Horizontal"> <datasetRun subDataset="ListDataSet" uuid="1316cfd7-fe59-440f-a155-501914c00056"> <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonQLDataSource)($P{REPORT_DATA_SOURCE})).subDataSource()]]></dataSourceExpression> </datasetRun> <jr:listContents height="30" width="100"> <textField> <reportElement x="0" y="0" width="90" height="30" uuid="4ee2d6b3-c681-433f-a170-4bb31697de58"/> <textFieldExpression><![CDATA[$F{val}]]></textFieldExpression> </textField> </jr:listContents> </jr:list> </componentElement> </band> </detail> <pageFooter> <band height="35" splitType="Stretch"> <textField> <reportElement x="0" y="2" width="100" height="30" uuid="ec089b7f-b752-43f9-afc5-fcf1cab1a12d"/> <textFieldExpression><![CDATA[$F{footer}]]></textFieldExpression> </textField> </band> </pageFooter></jasperReport>[/code]But when I print it - only the first element of an array appears:Perhaps, something is wrong with the pattern strings.*What am I doing wrong? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now