Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Saving Dynamic JSON output in CSV in Columns

Options
sushil
sushil Posts: 5

hi is there any way to save complete dynamic JSON output in csv in columns . right now i used write file and saved in CSV but it is saving in one row.

my expectation is to save all json values in csv with 2 columns , field name and field value.

i cant use data bank because json file is dynamic, one file might have 10 field and other might have 100 .

thank you in advance

Comments

  • jakubiak
    jakubiak Posts: 801 admin
    Options

    There is no automatic way to do this with SOAtest. I would recommend you write your own script/code to parse the JSON and write out the CSV in the format you desire.

  • sushil
    sushil Posts: 5
    Options

    thank you,

    so to parse, do i need to use data bank to pull all values first or can i read JSON output with script ?

  • jakubiak
    jakubiak Posts: 801 admin
    Options

    You would create a script that you could reference using an Extension Tool. It might be easiest to write a JavaScript script and use the Oracle Nashorn engine in the Extension Tool, so that you can use the JSON.parse() method that JavaScript has to parse the JSON. Then you would simply need to walk the JSON parse tree that you get from JSON.parse() and construct the CSV content as a string, which you would then return from your script method. In SOAtest you could then attach a Write File tool to write the contents to disk.

  • sushil
    sushil Posts: 5
    Options

    Thq will try