0

I have two lists that look like this:

List("key1", "key2")
List("val1", "val2")

I'm trying to get it into this JSON-like format:

[{"key1":"val1"},{"key2","val2"}]

Right now, this is what I'm using:

val output = List(attrKeys.zip(attrValues).toMap)

But it gives me this:

[{"key1":"val1","key2":"val2"}]

How do I get this into a list of separate map objects?

0

1 Answer 1

1
attrKeys.zip(attrValues).map(Map(_))
Sign up to request clarification or add additional context 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.