Created
August 19, 2014 18:53
-
-
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
This file contains 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
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