stefan.bugajczyk Posted May 5, 2023 Share Posted May 5, 2023 How can I print a list of strings (items) of a json file to a table in my report?{"propertyA": "sdsdfsdf","propertyB": "slkfgjdlfg","items": ["ITEM1","ITEM2"]} Link to comment Share on other sites More sharing options...
stefan.bugajczyk Posted May 5, 2023 Author Share Posted May 5, 2023 Ok, I finally resolved it.<subDataset name="myList"><field name="itemName" class="java.lang.String"><property name="net.sf.jasperreports.jsonql.field.expression" value="."/><fieldDescription><![CDATA[.]]></fieldDescription></field></subDataset>..<componentElement><reportElement positionType="Float" isPrintRepeatedValues="false" x="0" y="284" width="560" height="90" isRemoveLineWhenBlank="true" uuid="b8909323-e0d1-494b-a029-25352cbaf23e"><property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/><property name="com.jaspersoft.studio.table.style.table_header" value="Table_TH"/><property name="com.jaspersoft.studio.table.style.column_header" value="Table_CH"/><property name="com.jaspersoft.studio.table.style.detail" value="Table_TD"/><property name="com.jaspersoft.studio.components.autoresize.proportional" value="true"/></reportElement><jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd"><datasetRun subDataset="myList" uuid="d0f5042e-dda6-45ec-b033-2b6f4b9588b1"><dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("items")]]></dataSourceExpression></datasetRun><jr:column width="112" uuid="b5c22fe9-766e-468c-8ee3-b753f1a9a48b"><property name="com.jaspersoft.studio.components.table.model.column.name" value="Column2"/><jr:columnHeader style="Table_CH" height="30"><staticText><reportElement x="0" y="0" width="112" height="30" uuid="bf82d72a-4f7d-4a0a-8d56-a6506de3f072"/><text><![CDATA[Name]]></text></staticText></jr:columnHeader><jr:columnFooter style="Table_CH" height="30"/><jr:detailCell style="Table_TD" height="30"><textField><reportElement x="0" y="0" width="112" height="30" uuid="69977826-b68c-49f9-b73a-1d2d4e9faf67"/><textFieldExpression><![CDATA[$F{itemName}]]></textFieldExpression></textField></jr:detailCell></jr:column></jr:table></componentElement> Link to comment Share on other sites More sharing options...
anish.rai Posted May 8, 2023 Share Posted May 8, 2023 Thank you for posting to the Jaspersoft Community. Our team of experts has read your question and we are working to get you an answer as quickly as we can. If you have a Jaspersoft Professional Subscription plan, please visit https://support.tibco.com/s/ for direct access to our technical support teams offering guaranteed response times. Link to comment Share on other sites More sharing options...
Raphaël Peguet Posted May 12, 2023 Share Posted May 12, 2023 Yes it's possible to read json data and with a table or a chart it needs to be done through a sub dataset as you did.The data can also be passed through a parameter value the same way and using the jsonql query language. 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