Data Centric Exporters

Viewing: Working with Fields > Data Centric Exporters

Data Centric Exporters

Jaspersoft Studio supports two data-oriented export formats that are designed to be used programmatically when another application embeds TIBCO Jaspersoft products:

CSV: exports the report's data to a list of comma-separated values (CSV).
JSON: exports the report's data to a JavaScript Object Notation (JSON) object.

In both cases, the metadata defines the structure of the exported data.

Jaspersoft Studio also supports other types of field-level metadata:

PDF 508 Tags are used when creating report outputin Adobe Acrobat format that complies with the Americans with Disabilities 508 (c) specification.
XLS Tags are used to define how data is exported to the Microsoft Excel format. In addition to numerous layout settings, you can define XLS metadata that define the structure of the data when it is exported.

This section describes how to work with metadata for the JSON exporter.

Configuring a Report's Metadata for Use With the JSON Data Exporter

JasperReports Server's REST API includes a JSON (JavaScript Object Notation) data exporter that provides the ability to feed pure data into applications you integrate with the server. During report generation, this exporter skips all layout-related steps and returns a dataset. The structure of this data is determined by metadata you define in your report. You can also define expressions to manipulate how data from a specific filed is exported.

Note: The ability to define metadata and export data in JSON format is sometimes referred to as the JasperReports Data API.

You can define a structure by separating the names of the levels you want to create with periods (.). For example, consider a report with three fields configured with these JSON properties:

Field Expression





When exported to JSON, the data is structured with three distinct paths:







Example exported data would be similar to:





sale:[{amount:"19000", year:2014}],






Note that when you preview your report as JSON, the data is not formatted to be human readabable, as above. You may want to use one of the many JSON formatting tools to review the output of your JSON tagged report, you can copy the JSON output from the Preview tab.

It is important to define paths that create a structure that the application receiving the data can interpret.

To define JSON export object metadata in your report:

1. Open a report that includes the fields you want to export to your application.
2. Right-click a field in the Design tab, and select JSON tags > JSON Metadata Path.

If the field you selected appears in a frame, you are prompted that JasperReports Library may ignore the property. This warning relates only to older versions of the library; it remains in the product for backwards-compatibility reasons. For current versions of JasperReports Server, JasperReports Server, and Jaspersoft Studio, properties defined in frames aren't ignored.

3. If you receive this warning, click OK.

The JSON Exporter Property Configuration window appears.

4. In the Path field, enter a string that defines the way you want the data from this field to be exported. For example, if you are working with a field that returns a sales amount value, you might enter
5. If the data being returned necessitates it, check the Repeat value if missing check box.

This option is helpful if your source data doesn't include values for every row of data returned. Selecting this option instructs Jaspersoft Studio to simply use the last value passed when a value is missing, which may prevent problems in the application receiving the JSON object.

6. If you want to manipulate the data being exported, check the Use custom expression for exported value check box, click , and define an expression.
7. Click OK.
8. Select each of the fields you want to have exported to JSON and define their metadata.
9. Click File > Save.
10. Click Preview.
11. If the JSON Metadata preview isn't selected, click the arrow next to the current preview format, and select JSON Metadata.

Selecting the JSON Metadata Preview

12. Review the structure of the data to ensure your application can interpret it.
13. If the data isn't structured correctly, click Design and edit each field's JSON export properties.
14. When you are satisfied with the data being returned by Jaspersoft Studio, you can publish your report to JasperReports Server and begin testing your own application's ability to use the data passed by the server.