Script to capture JSON elements in Excel

AbhiAbhi Posts: 2

Hi Team,
I have a situation where i have to fetch the values from JSON response and write those in excel in different predefined columns. I have created JSON data bank and captured the required values. Then i add an extension tool to fetch the data bank values , but now not able to write those values in excel . Need help !
Please find below the Jython code i have created .
from com.parasoft.api import *;
from soaptest.api import *;
from java.util import *;

def readData(input, context):
#data = addDataSource(context)
val1 = context.getValue("Generated Data Source", "Test 1: viccVehicleCd")
val2 = context.getValue("Generated Data Source", "Test 1: viccExtensionCd")
#val3 = context.getValue("ww", "index")
#return val3
# return val1
#return val1
#arraycd = ArrayList()

#for index in arraycd:


 Note : i also used Write file to generate csv file but that is of not much use for my scenario.   


  • OmarROmarR Posts: 207 admin

    Hey Abhi! Happy New Years!!!!!

    The simplest way to accomplish your scenario is to store your extracted-data into a writable-datasource and manually import it into an Excel or CSV file.

    That being said, there IS another way to import data into a CSV file using the almighty.....XPATH! I did a quick search on our forum and found an example on how to go about this!

  • AbhiAbhi Posts: 2

    Thank you Omar !
    But our situation is bit different . We have around 10,000 sets of data and it would be tedious to manually put the data in excel. Also we want to make the framework dynamic.
    For the second option you provided , we have JSON responses , so XPath is not suitable here , we have to work with JSON databank.
    We are able to create the framework using Java and can create the Request XML files :)
    Now , not sure , how to automate this part where we can pass the Xml files as request for the REST service. In SOAtest we have an option to pass one XML file as request at a time , but could you please help to provide any solution where we can pass multiple files one by one without manual intervention as we do while data parameterization.


Sign In or Register to comment.