How to Create a JSON Array from Results at JDBC Test Step in SOAPUI NG Pro
Hi Team
I have a Requirement to create a JSON payload from JDBC Test Step Values dynamically and send it as Request to my rest service. How Can I write the groovy script to fetch the values from JDBC Test Step.
Sample
<Results>
<ResultSet fetchSize="10">
<Row rowNumber="1">
<ORDERID>H001</SOURCEORDERID>
<LINEID>L001</SOURCELINEID>
<HOLDID>1</HOLDID>
<HOLDNAME>HOLDA</HOLDNAME>
<RELEASED_FLAG>N</RELEASED_FLAG>
</Row>
<Row rowNumber="2">
<ORDERID>H001</SOURCEORDERID>
<LINEID>L001</SOURCELINEID>
<HOLDID>2</HOLDID>
<HOLDNAME>HOLDB</HOLDNAME>
<RELEASED_FLAG>N</RELEASED_FLAG>
</Row>
<Row rowNumber="3">
<ORDERID>H001</SOURCEORDERID>
<LINEID></SOURCELINEID>
<HOLDID>3</HOLDID>
<HOLDNAME>HOLDC</HOLDNAME>
<RELEASED_FLAG>N</RELEASED_FLAG>
</Row>
</ResultSet>
</Results>
Thanks
Jayant Agarwal
Please find the script below:
https://github.com/nmrao/groovyScripts/blob/master/json/ConvertDBResultToJson.groovy
Use log.info instead of println
You can quickly run try this quickly online as well