Convert array to json for separation of items?

I have the following code:

const returnCodeList = conceptsComp.getWrappedInstance().returnCodeList()
                let companyList = []
       => {

And the console.log(companyList) prints the following :

Array [ "Company 11", "\\MNSCP_DX\\" ]

Since, I am sending this value while calling a web service, I want to separate it like the following, separated by |:

			Company 11 | \\MNSCP_DX\\

Do I need to first convert the companyList array to JSON and then apply the separation logic?

Hi @Jack_Tauson_Sr, you mean as a single string? You can then just join() the array… BTW using map() there’s no need to push() to another array, just map to the desired property directly:

const companyList = => item.company_path)
const joined = companyList.join(' | ')

console.log(joined) // "Company 11 | \\MNSCP_DX\\"

Hi @m3g4p0p , Yes, that’s what I was looking for. Thanks very much.

1 Like