Forum Discussion

Shashavali's avatar
Shashavali
Contributor
7 years ago

how to read values from json file as we can from Excel or .txt file

Hi,   I am trying to read the values from .json file format by using Data Source Step. By it says file format unsupported.   I am successfully able to read values using Excel and Text file. Is it...
  • ChrisA's avatar
    7 years ago

    Hi,

     

    When creating the datasource, you have noted that whilst JSON is an option, there is no way to read in from files.  So, do that.

     

    Firstly, create a Groovy step.  In the Step return the contents of the JSON file.

     

     

    def file1 = new File('C:/temp/temp.json');
    
    return file1.text;

     

     

    If you run this step on its own, you should get a pop-up that shows the contents of the file.  If you don't check the path and file name.

     

    Then, create your data source step.  Select JSON from the DataSource dropdown.  Then, from the 'Source Step' dropdown, select the Groovy step created earlier.  From the Source Property dropdown, select 'Result'.

     

    From here, you just need to define the properties of the JSON object.