Created
March 6, 2014 02:40
-
-
Save brentsowers1/9381211 to your computer and use it in GitHub Desktop.
Parsing JSON in to a Map with Lift JSON
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import net.liftweb.json._ | |
val jsonStr: String = """{"key1":"value1","key2":1}""" | |
val jsonJVal: JValue = parse(jsonStr) | |
val jsonMap: Map[String,Any] = jsonJVal.values.asInstanceOf[Map[String,Any]] | |
for ((key,value) <- jsonMap) { | |
println("key = " + key + ", value = " + value.toString) | |
} | |
println("Key 1's value is " + jsonMap("key1")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment