Scala将字符串转换为地图 [英] Scala Convert a string into a map
本文介绍了Scala将字符串转换为地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
{a:ab,b:cd, c:cd,d:de,e:ef,f:fg}
在scala中变成可变地图?我从〜500MB的文件中读取这个输入字符串。这就是我关心速度的原因。安德烈说,
解决方案
看起来像一个JSON文件。您应该考虑这个答案。它给出了一些例子Scala代码。此外,此回答还提供了一些不同的JSON库及其相对优点。
What is the fastest way to convert this
{"a":"ab","b":"cd","c":"cd","d":"de","e":"ef","f":"fg"}
into mutable map in scala ? I read this input string from ~500MB file. That is the reason I'm concerned about speed.
解决方案
That looks like a JSON file, as Andrey says. You should consider this answer. It gives some example Scala code. Also, this answer gives some different JSON libraries and their relative merits.
这篇关于Scala将字符串转换为地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文