Skip to content

Instantly share code, notes, and snippets.

@nickmoorman
Created August 19, 2014 18:53
Show Gist options
  • Save nickmoorman/b01f5ed165aa99f59e92 to your computer and use it in GitHub Desktop.
Save nickmoorman/b01f5ed165aa99f59e92 to your computer and use it in GitHub Desktop.
Creating a JSON response from a map with Play Scala 2.3.x
package controllers
import scala.collection.mutable.{Map => MMap}
import play.api.libs.json.{Json, JsValue}
import play.api.mvc._
object Application extends Controller {
def index = Action {
var result = MMap("status" -> "ok")
result += "field" -> "value"
result += "another" -> "wheeeee"
Ok(Json.toJson(result.toMap))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment