05-01-24 07:57 AM
Hi Team ,
I need to convert JSON to CSV. for this I am first converting JSON to collection using JSON to collection(Skipping JArray) but I am getting output like below
I basically need 3 columns for csv output : host, included and Instance
I dont have issue in getting host and included but for instance, sometimes it has single value and sometime it has multiple in array
I need instance column value ( If it has multiple values, it should fetch first value) .
Could you please help in extracting first value of instance from below collection ?
Output
host ,included, instances[0]
yesterday
Hi @kirtish.trivedi - you can follow below steps to achieve that.
create one collection and named as tempcol
create another collection and named as finalCol
next, loop through your main collection
under loop use calculation stage to store instances in tempcol using maincol.instances store in tempcol
next, in templcol collection using collection manipulation object append one text column with value as host and the host value which is in loop working value
next, do the same step for included column
next, using collection manipulation object, append collection from tempCol to finalCol
next, clear/rest tempcol
loop will go on until last row