Problem with JSON dataset

0

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.

 

_freeman_'s picture
Joined: Apr 3 2012 - 7:11am
Last seen: 2 weeks 3 days ago

1 Answer:

1

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>

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.expression

2. JSON/JSONQL expressions are case sensitive

3. 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

narcism's picture
1177
Joined: Nov 22 2010 - 12:39am
Last seen: 7 hours 36 min ago

Thank you very much @narcism, it is answered my question to the detail and solved my problems.

_freeman_ - 2 weeks 3 days ago
Feedback
randomness