How to filter a json list in a jasper report

0
Hi all, I have a json source for a report that contains a list like
 
<pre language="javascript">
"DescrDescriptionShort":[  
   {  
      "language":{  
         "label":"Language",
         "tooltip":"bla bla",
         "value":"German",
         "type":"CodeKeyType"
      },
      "descriptionShort":{  
         "label":"Description",
         "tooltip":"bla bla",
         "value":"Mini Frösche Bonbons",
         "type":"String"
      }
   },
   {  
      "language":{  
         "label":"Language",
         "tooltip":"bla bla",
         "value":"Danisch",
         "type":"CodeKeyType"
      },
      "descriptionShort":{  
         "label":"Description",
         "tooltip":"bla bla",
         "value":"Mini frogs",
         "type":"String"
      }
   }
]
</pre>
 
Id like to get the text fields with descriptionShort.label and descriptionShort.value but only for language.value == German. So first I tried to create a sub data set like 
bellow and use it in my list:
 
<subDataset name="descrDataset" uuid="ec0a8e9b-ea20-4b64-9363-5668c90a2f04">
<queryString language="JSON">
<![CDATA[language.value == German]]>
</queryString>
<field name="descr-label" class="java.lang.String">
<fieldDescription><![CDATA[descriptionShort.label]]></fieldDescription>
</field>
<field name="descr" class="java.lang.String">
<fieldDescription><![CDATA[descriptionShort.value]]></fieldDescription>
</field>
<field name="language" class="java.lang.String">
<fieldDescription><![CDATA[language.value]]></fieldDescription>
</field>
</subDataset>
 
But it seems that queryString exprecions has no impact - the list displays all values. I also tries
 
<field name="descr" class="java.lang.String">
<fieldDescription><![CDATA[DescrDescriptionShort(language.value == German)[0].descriptionShort.value]]></fieldDescription>
</field>
 
But this causes an Exception "net.sf.jasperreports.engine.JRException: Invalid attribute selection expression: ZasDescrDescriptionShort(language."
 
Any Idea how I can filter a json list in a jasper report?
 
Many thanks and regards,
Andrej
epistolarum's picture
Joined: Sep 2 2016 - 6:39am
Last seen: 2 years 11 months ago

I didn't fond a solution with a filter, but I resolved the issue with following solution.

1. I defined a language.value field for the subdataset.

2. Add a print when expression for the list fields

epistolarum - 2 years 11 months ago

0 Answers:

No answers yet
Feedback
randomness