anatoly.weinstein Posted April 28, 2023 Share Posted April 28, 2023 I am new to Jasper and I am trying to do something like in the snippet below to get "value" of the "node" from the "proposal.proposalFees.nodes" array with "node.type" equal "KEY_2".Obviously, the below snippet doesn't work. Question: how to do it properly?The goal is that "$F{KeyTwoValue}" value displays "56000" in expressions (see sample data below).Any input would be greatly appreciated. <queryString language="json"> <![CDATA[proposal]]> </queryString> <field name="KeyTwoValue" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression"> <![CDATA[proposalFees.nodes[type == "KEY_2"].value]]> </property> </field>[/code]Input source:{ "proposal": { "proposalFees": { "nodes": [ { "value": 20000, "type": "KEY_1" }, { "value": 56000, "type": "KEY_2" } ] } }}[/code] Link to comment Share on other sites More sharing options...
anatoly.weinstein Posted May 2, 2023 Author Share Posted May 2, 2023 Actually, I have found an answer to my question here: jsonql datasource referenceThis page has a good comparison for syntax and capability of JSON and JSONQL.In question (with language="json") the proper field definition will looks like this: <field name="KeyTwoValue" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="proposalFees.nodes(type == KEY_2).value[0]"/> </field>[/code] Link to comment Share on other sites More sharing options...
Solution Mehak Rajkumar Posted May 2, 2023 Solution Share Posted May 2, 2023 jsonql datasource referenceThis page has a good comparison for syntax and capability of JSON and JSONQL.In question (with language="json") the proper field definition will looks like this: <field name="KeyTwoValue" class="java.lang.String"> <property name="net.sf.jasperreports.json.field.expression" value="proposalFees.nodes(type == KEY_2).value[0]"/> </field>[/code] Link to comment Share on other sites More sharing options...
Mehak Rajkumar Posted May 2, 2023 Share Posted May 2, 2023 We are delighted to know that you have found the answer to your question. Thank you for taking the time to post it on the Jaspersoft Community. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now