Jump to content
Changes to the Jaspersoft community edition download ×

Java creating a JsonDataSource using a JsonNode object


walid.asansas

Recommended Posts

Hello,

I have the following use case: we have a JsonNode object coming from our persistence layer, we want to create a JsonDataSource using that JsonNode object before filling a Jasper Report. Now the question is: why do we have to convert that JsonNode to InputStream before creating the JsonDataSource? While checking the code source of the JsonDataSource class I can see the following constructor:

    protected JsonDataSource(JsonNode jsonTreeString selectExpressionthrows JRException {

But it is coded as protected and we can't call it in our case, we found out that converting the object to InputStream in order to use the public constructor, which will in fact convert the object back to a JsonNode, is not optimal and therefore I would like to know if there is any fix for this case?

public JsonDataSource(InputStream jsonStreamString selectExpressionthrows JRException {
        this(JsonUtil.parseJson(jsonStream), selectExpression);
    }



Thank you for your efforts!

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...