2

I want to use data from a DSpace REST API in a Jasper report. I have successfully created a data adapter with type "JSON File" and provided the resource URL and set GET as request type. When I use that data adapter in my report, I can edit its options and when I click "Read Fields" in Jaspersoft Studio, I see the tree of nested JSON objects according to my request, as expected.

I now want to use different of levels of the JSON in the fields of my report. This works fine for the top level values, however, when I try to access the nested values using dot notation, no data is displayed in the report.

Example:

<field name="sections.publications_result.dc.title.value" class="java.lang.String">
    <property name="net.sf.jasperreports.jsonql.field.expression">
        <![CDATA[sections.result.dc.title.value]]>
    </property>
</field> 

How do I get the nested values?

1 Answers1

2

The problem is that there are dots (.) in the names of your JSON response. I guess Jasper assumes that each dot denotes one sublevel. You need to "escape" those identifiers that have a dot in them.

E.g., if dc.title is one identifier,

sections.result.dc.title.value

needs to be changed to

sections.result["dc.title"].value 

in your "Field Expression".

buddemat
  • 4,552
  • 14
  • 29
  • 49