How to acces value of field from another data source (JSON)?

0

Hello

I'm creating a report using two datasources (the format is JSON).

The structure of JSON is like:

{    
    "first":
        {
            "parameter1" : 123,
        },
    "second":[
        {
            "key" : 1,        
        },{
            "key" : 2,        
        }
    ]
}

So I have two datasources. One for the first object (firstSource) and another (secondSource) for second object (array of objects).

The array (second) is printed in the table component. I'd like to access a field from first object (first.parameter1) and print it in the table header.

The table is using this dataset:

<datasetRun uuid="4ee63b06-f4ee-45b4-9da8-3dabc3e7a09d">
                        <dataSourceExpression><![CDATA[$P{secondSource})]]>
                        </dataSourceExpression>
</datasetRun>

Then I'm printing its fields using $F{key}.

Do you know how can I access the parameter1 of the first object from table? Maybe using some sort of $V{} variable or merging both datasources?

I tried to use subDataSource and subDataSet approach without any luck.

Here's something I'd like to achieve in the result table:

first.parameter1
second[0].key
second[1].key

gagarin's picture
Joined: Aug 8 2018 - 5:31am
Last seen: 1 year 2 weeks ago

Why not have the whole JSON data populating the main data source?

narcism - 1 year 2 weeks ago

0 Answers:

No answers yet
Feedback
randomness