It really depends on what you have in these Strings. Problem is that .toString on its own looses some information:
@ Map("test" -> 1).toString
res1: String = "Map(test -> 1)"
@ Map("debug -> 2, test" -> 1).toString
res2: String = "Map(debug -> 2, test -> 1)"
@ Map("debug" -> 2, "test" -> 1).toString
res3: String = "Map(debug -> 2, test -> 1)"
How would you figure out if you have case from res2 or res3? In general if any of these Strings you used as keys contains , you will have some problematic case as there either will be ambiguities or syntax errors (if you attempt to parse things).
However, if you didn't have those you can:
- remove initial
Map( and final ) using .substring
*.split the result using '","' as a separator
.map thw result to .split key from value, trim both sides
- then the only issue would be parsing the values (
AnyRefis not very specific).
Alternatively:
- open Sublime Text (or any other editor with multiline edition support)
- paste your code there
- select
-> and use it for multiline select in whole file
- use ctrl+arrows to add
" around key to make it parsable String
- use the same method for adjusting
AnyRefs if needed
- copy code back into Scala and evaluate