Jump to content
Changes to the Jaspersoft community edition download ×

json array as comma separated values into single field


2340patel

Recommended Posts

Hi have below json 

"markets": [
  {
    "id": "1001",
    "name": "val1"
  },
  {
    "id": "1002",
    "name": "Val2"
  },
  {
    "id": "1003",
    "name": "val3"
  }
]

I wanted to display name field into single text fields with comma separated value. I tried declaring variable as follows

 <variable name="allVall" class="java.lang.String">
            <variableExpression><![CDATA[($V{allVall} != null)?($V{allVall} + $F{name}) :( $F{name})]]></variableExpression>
        </variable>
        
then using the variable in text field as

                <jr:listContents height="20" width="119">
                        <textField isStretchWithOverflow="true" evaluationTime="Report">
                            <reportElement stretchType="ElementGroupHeight" x="0" y="0" width="119" height="20" uuid="35355db6-36be-47f3-b346-ba1f5e5c6919">
                                <property name="com.jaspersoft.layout.grid.weight.fixed" value="false"/>
                                <property name="net.sf.jasperreports.style.box.pen.lineStyle" value="Solid"/>
                            </reportElement>
                            <box>
                                <pen lineWidth="1.0" lineStyle="Solid"/>
                                <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                                <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                            </box>
                            <textElement verticalAlignment="Middle">
                                <font fontName="Arial" size="10"/>
                            </textElement>
                            <textFieldExpression><![CDATA[$V{allVall}]]></textFieldExpression>
                        </textField>
                    </jr:listContents>
                    
however still values are displayed as text fields in list component    as multiple text fields. 
I want single text fields with comma separated value. 

can someone pls guide on same. 

Thanks,
Anjana. 

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

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