Jump to content
We've recently updated our Privacy Statement, available here ×

SubDatasets (lists inside lists) in json?


inanutshellus
Go to solution Solved by inanutshellus,

Recommended Posts

Jasper Reports comes with a sample report using a JSON datasource, and the "jsonCustomerReport" shows exactly what I want it to, but it does so by requerying the entire datasource for each subreport, like so:

 


 

<subreportParameter name="net.sf.jasperreports.json.source">

<subreportParameterExpression><![CDATA["data/northwind.json"]]></subreportParameterExpression>

</subreportParameter>


 

Let's say I wanted the Customer Report that looks like this:

 

    Maria Anders of Beverly Hills

        Order #100 

        Order #101

    Ana Trujillo of New York City

        Order #102

        Order #103

        Order #104

 

 

But using this data as a string passed in as an InputStream:

 

    {"SomeJsonObject": {

      "Customers": [ {

          "ContactName": "Maria Anders",

          "CustomerID": "ALFKI",

          "Address": {

              "Street":"123 Sesame St",

              "City":"Beverly Hills"

          },

          "Orders": [ {

              "OrderID": 100 // Other stuff snipped

            }, {

              "OrderID": 101

            }

          ]

        }, {

          "ContactName": "Ana Trujillo",

          "CustomerID": "ANATR",

          "Address": {

              "Street":"456 Sesame St",

              "City":"New York City"

          },

          "Orders": [ {

              "OrderID": 102

            }, {

              "OrderID": 103

            }, {

              "OrderID": 104

            }

          ]}

        ]}

    }

 

 

How would I access the Orders array?

 

I wanted to use a SubDataSet and a List component, but I don't know what to put for the `dataSourceExpression`.

 

Link to comment
Share on other sites

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

  • 2 weeks later...
  • 1 month later...
  • 1 month later...
  • 1 year later...

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...