Forum Discussion

flavia_sarah's avatar
flavia_sarah
New Contributor II
5 years ago
Solved

Create Key Value Pair instead of List/Array

Expression for Conversation.Text = $[‘$ConversationPost.Text’].toString().split(“|”).map((elem, index) => [elem])

Mapper Output:

The desired output is:
“ConversationPost” : {
“Text”: “comment #2 US142”,
“Text”: “comment #1 US142”,
“Artifact” : “/hierarchicalrequirement/…”
}

Not sure where did I go wrong.
Is there any possible way to achieve this output?

2 Replies

  • The map() function returns a list of values, the value you are returning, [elem] from the map call, is a list as well. So the resulting value will always be a list of lists with this expression. Also, I noticed your data has duplicate keys. Using the same key will override the previous value stored at that key text, so I would recommend using the unique keys like given in the example by @Spiro_Taleski