1

I am using Gatling and want to use feeders. Apparently, feeders require a List[Map[String, String]]. I have a list of tuples like

{("key", "abcde"),("key", "bcdef")...}

and I want to convert it into

{ Map("key", "abcde"), Map("key", "bcdef")...}

How can I do that? I am new to Scala programming and would appreciate any help here.

1
  • 2
    It's impossible to have duplicate keys in map. Commented Apr 20, 2019 at 6:10

2 Answers 2

1

Try this:

val tupleList = List(("key", "abcde"),("key",           "bcdef"))                                                              
val mapList = tupleList map { case (k,v) => Map(k-> v)}         
Sign up to request clarification or add additional context in comments.

Comments

0

try this:

val x: List[(String, String)] = List(("key", "abcde"),("key", "bcdef"))
val y: List[Map[String, String]] = x.map(p => Map(p._1 -> p._2))

since you are creating new Map for every tuple so duplicate key should not be an issue as suggested in comments

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.