为什么toJson
和parse
为同一个字符串提供不同的输出(而不是使用\"
时的其他toJson
。
scala> import play.api.libs.json._
import play.api.libs.json._
scala> val bodyAsString = """{"result":"error","additional-info":"Incorrect body type. Body type must be JSON"}"""
bodyAsString: String = {"result":"error","additional-info":"Incorrect body type. Body type must be JSON"}
scala> val j1 = Json.parse(bodyAsString)
j1: play.api.libs.json.JsValue = {"result":"error","additional-info":"Incorrect body type. Body type must be JSON"}
scala> val j2 = Json.toJson(bodyAsString)
j2: play.api.libs.json.JsValue = "{\"result\":\"error\",\"additional-info\":\"Incorrect body type. Body type must be JSON\"}"