What is the fastest way to convert this
{"a":"ab","b":"cd","c":"cd","d":"de","e":"ef","f":"fg"}
in volatile mapping in scala? I read this input line from ~ 500 MB file. It is for this reason that speed bothers me.
It looks like a JSON file, as Andrew says. You should consider this answer . It provides an example of Scala code. In addition, this answer gives some different JSON libraries and their relative merits .
JSON , , .. /, . Scala:
myString.substring(1, myString.length - 1) .split(",") .map(_.split(":")) .map { case Array(k, v) => (k.substring(1, k.length-1), v.substring(1, v.length-1))} .toMap
XML JSON API: Jackson Streaming API JSON.
, " " " ", , .