Use a Jsonql data source from Stringiest instead of file

0

Hello all.

I need to create a report that shows data from Jsonql data source but, instead of reading this data from a file, reads it from a Json string?

Regards

julio_12's picture
Joined: Jul 2 2019 - 4:05pm
Last seen: 6 days 16 hours ago

2 Answers:

1

Your answer can be found in this stackoverflow post: https://stackoverflow.com/a/37441567/5882963

in the 'EDIT' section.

In essence, you could use two parameters, one with the actual data and the other specific to JasperReports internals:

<parameter name="jsonString" class="java.lang.String">
  <defaultValueExpression><![CDATA["{\"a\": [ {\"b\": { \"val\": \"val1\"}}, {\"b\": { \"val\": \"val2\" }}]}"]]></defaultValueExpression>
</parameter>
<parameter name="JSON_INPUT_STREAM" class="java.io.InputStream">
  <defaultValueExpression><![CDATA[new java.io.ByteArrayInputStream($P{jsonString}.getBytes("UTF-8"))]]></defaultValueExpression>
</parameter>

the query language can be either JSONQL or JSON.

narcism's picture
1027
Joined: Nov 22 2010 - 12:39am
Last seen: 53 min 53 sec ago
0

Thank you for the explanation!

I'll try it and let you know the results.

julio_12's picture
Joined: Jul 2 2019 - 4:05pm
Last seen: 6 days 16 hours ago
Feedback
randomness