Forum Discussion
Can you please advise how to take a list of values (e.g. in Excel) and then convert that to json array. I am getting values from excel in DataSource but I am unable to convert those values to json in request body editor.. Please find the attachments. in request body I need json like below
[
{
"tcId":"ab1",
"tcName":"ab1",
"tcDesc":"abc1",
"tcType":"Other",
"tcPriority":"Low"
}]
Can anybody help me to get json body as above?
Thanks & Regards,
Gangadhar Badagi
Gangadhar, the approach I took is not to build the JSON string on the fly, which can get tricky. Instead what I did is provide teh JSON string in my excel file and using place holders for the values. for instance:
so in my excel what I have is 5 columns,
column name tcId tcName request
column value 1234 test1 [{"tcId":"<tcId>","tcName":"<tcName>","tcDesc":"<tcDesc>","tcType":"<tcType>","tcPriority":"<tcProperity>"}]
so basically what I do is go through each variable inside <> and replace it with the value under each column.
[
{
"tcId":"<tcId>",
"tcName":"<tcName>",
"tcDesc":"<tcDesc>",
"tcType":"<tcType>",
"tcPriority":"<tcProperity>"
}]