_freeman_ Posted May 19, 2020 Share Posted May 19, 2020 How can I fill data from json dataset that are not part of the array?Only array values get filled: I searching for solution without table, because I have a long text that needs to be shown, and tables not working correctly with cells on one or more pages.I've attached test jrxml and json file.Thank you very much. Link to comment Share on other sites More sharing options...
Solution narcism Posted May 20, 2020 Solution Share Posted May 20, 2020 I'm posting only the relevant part, the query and the field mappings:<queryString language="jsonql"> <![CDATA[list.*]]></queryString><field name="keyA" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="keyA"/> <fieldDescription><![CDATA[keyA]]></fieldDescription></field><field name="keyB" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="keyB"/> <fieldDescription><![CDATA[keyB]]></fieldDescription></field><field name="keyC" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="keyC"/> <fieldDescription><![CDATA[keyC]]></fieldDescription></field><field name="Title" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="^{2}.title"/> <fieldDescription><![CDATA[Title]]></fieldDescription></field><field name="Author" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="^{2}.AUTHOR"/> <fieldDescription><![CDATA[Author]]></fieldDescription></field><field name="Date" class="java.lang.String"> <property name="net.sf.jasperreports.jsonql.field.expression" value="^{2}.DATE"/> <fieldDescription><![CDATA[Date]]></fieldDescription></field>[/code]Some notes:1. If you manually change the query language, from JSON to JSONQL, you also need to adjust the field-level properties to use the proper name: net.sf.jasperreports.jsonql.field.expression2. JSON/JSONQL expressions are case sensitive3. The JSONQL expression "^{2}.title" implies going up 2 levels from whatever your main query item points to, then select "title"4. If your JSON data is part of a bigger JSON tree, then you need to adjust your main query expression from "list.*" to "..list.*" which will look for the "list" key anywhere in the JSON tree Link to comment Share on other sites More sharing options...
_freeman_ Posted May 20, 2020 Author Share Posted May 20, 2020 Thank you very much @narcism, it is answered my question to the detail and solved my problems. Link to comment Share on other sites More sharing options...
rajesh.anandalai_1 Posted July 27, 2020 Share Posted July 27, 2020 It worked ! 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