Jump to content
We've recently updated our Privacy Statement, available here ×
  • How to query a file-based JSON datasource


    ghudson_1
    • Features: Data Sources Version: v8 Product: iReport Designer

    Issue Description:

    iReport Designer v4.5.1/ Jaspersoft Studio Professional 8.2  and greater offers a JSON Datasource.

    Below are some ideas for getting started with JSON datasources for your report.  

    [toc]

    We'll use a sample of a single record, like:

    { "item" : [{ "value" : 895, "text" : "test" }] }
    

    Resolution:

    1. In the "JSON file" field you must browse locally or via shares to a text file containing your json data. 

    2. Choose "Use the report JSON Expression when filling the report" to be able to specify your query within the individual report.

    3. In iReport's "report query", choose json in the drop-down.  For our sample, try a query like:

      <queryString language="json">
          <![CDATA[item]]>
      </queryString>
      
    4. Next you need to manually create fields, matching the names of our json data, then treat this like any other report source:

      <field name="value" class="java.lang.Integer">
          <fieldDescription>
              <![CDATA[value]]>
          </fieldDescription>
      </field>
      <field name="text" class="java.lang.String">
          <fieldDescription>
              <![CDATA[text]]>
          </fieldDescription>
      </field>
      

    As for query syntax, currently we only support only simple (single) filtering criteria with these operators: <, <=, >, >=, == and !=.

    An example query with an operator to return only the line we've specified via an Input Control might be :

    <queryString language="json">
        <![CDATA[item(value == $P{myValueInput})]]>
    </queryString>
    

    Ref. Case #00033486

    ejemplojson.json


    User Feedback

    Recommended Comments

    There are no comments to display.



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