Skip to content

Instantly share code, notes, and snippets.

@prayagupa
Last active February 16, 2017 09:41
Show Gist options
  • Save prayagupa/b17e0f5878ce09804129851510ea6790 to your computer and use it in GitHub Desktop.
Save prayagupa/b17e0f5878ce09804129851510ea6790 to your computer and use it in GitHub Desktop.
scala
import scala.util.parsing.json.JSONObject
/**
* Created by prayagupd
* on 2/16/17.
*/
object Test {
def main(args: Array[String]): Unit = {
val s = List(JSONObject(Map("language" -> "scala", "desc" -> "too many libraries")),
JSONObject(Map("language" -> "java", "desc" -> "too many libraries")),
JSONObject(Map("language" -> "clojure", "desc" -> "too many libraries")))
println(s"${s.mkString(",")}")
}
}
//output
// {"language" : "scala", "desc" : "too many libraries"},{"language" : "java", "desc" : "too many libraries"},{"language" : "clojure", "desc" : "too many libraries"}
import scala.util.parsing.json.{JSON, JSONType}
/**
* Created by prayagupd
* on 2/16/17.
*/
object Test {
def main(args: Array[String]): Unit = {
val json =
"""
{
"language" : "scala",
"desc" : "toooo many libraries"
}
""".stripMargin
val jsonType : JSONType = JSON.parseRaw(json).get
val s = List(jsonType, jsonType, jsonType)
println(s"${s.mkString(",")}")
}
}
//output
// {"language" : "scala", "desc" : "toooo many libraries"},{"language" : "scala", "desc" : "toooo many libraries"},{"language" : "scala", "desc" : "toooo many libraries"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment