Field name with dot in Json datasource using ireport

0

My sample json file content

{
"FlightLog":{
    "FlightLog.crewMembers":[
 
    ],
    "destinationStationCode":"JPN",
    "FlightLog.destinationStationCode":"IND",
    "FlightLog.originStationCode":"IND",
    "FlightLog._lockVersion":"0",
    "FlightLog.flightNum":"123"
}
}

I want to get value for FlightLog.FlightLog.originStationCode.

for eg: When i declare field name as below , i am getting the value "JPN"

<field name="FlightLog.destinationStationCode" class="java.lang.String">
    <fieldDescription><![CDATA[FlightLog.destinationStationCode]]></fieldDescription>
</field>

Whereas if i declare field as below,

<field name="destinationStationCode" class="java.lang.String">
    <fieldDescription><![CDATA[FlightLog.FlightLog.destinationStationCode]]></fieldDescription>
</field>

I am not getting any value for the above code.

I tried using

<field name="destinationStationCode" class="java.lang.String">
    <fieldDescription><![CDATA[FlightLog[FlightLog.destinationStationCode]]]></fieldDescription>
</field>
<field name="destinationStationCode2" class="java.lang.String">
    <fieldDescription><![CDATA[FlightLog.FlightLog\\.destinationStationCode]]></fieldDescription>
</field>

How can i do this?

arasu_se's picture
Joined: Apr 19 2015 - 9:21pm
Last seen: 4 years 5 months ago

1 Answer:

0

This will be possible in JasperReports Library and JasperSoft Studio starting with version 6.3.1. iReport is no longer supported as of version 5.5.0.

With this release, a new JSON query language(JSONQL) will be available for use. It is meant to replace the existing language for querying JSON data. New sample with extensive documentation will be available in the Data Source / Query Executer section of the sample reference page(http://jasperreports.sourceforge.net/sample.reference.html) once the 6.3.1 release is out.

Your jrxml is, most likely, going to look like this:

<queryString language="jsonql">

<![CDATA[FlightLog]]>

</queryString>

<field name="DestinationStationCode" class="java.lang.String">

<propertyExpression name="net.sf.jasperreports.jsonql.field.expression"><![CDATA["[\"FlightLog.destinationStationCode\"]"]]></propertyExpression>

</field>

<field name="OriginStationCode" class="java.lang.String">

<propertyExpression name="net.sf.jasperreports.jsonql.field.expression"><![CDATA["[\"FlightLog.originStationCode\"]"]]></propertyExpression>

</field>

<field name="LockVersion" class="java.lang.String">

<propertyExpression name="net.sf.jasperreports.jsonql.field.expression"><![CDATA["[\"FlightLog._lockVersion\"]"]]></propertyExpression>

</field>

<field name="FlightNum" class="java.lang.String">

<propertyExpression name="net.sf.jasperreports.jsonql.field.expression"><![CDATA["[\"FlightLog.flightNum\"]"]]></propertyExpression>

</field>

narcism's picture
1122
Joined: Nov 22 2010 - 12:39am
Last seen: 2 hours 14 min ago
Feedback
randomness