为什么Json.toJson和Json.parse为相同的字符串提供不同的输出

时间:2018-06-13 12:36:38

标签: playframework-2.6

为什么toJsonparse为同一个字符串提供不同的输出(而不是使用\"时的其他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\"}"

0 个答案:

没有答案