Scala Convert string to map

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.

+4
source share
3 answers

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 .

+1
source

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
+8

XML JSON API: Jackson Streaming API JSON.

, " " " ", , .

+2

All Articles