Converting JSON string to a JSON object in Scala

后端 未结 4 883
生来不讨喜
生来不讨喜 2020-12-31 04:07

I want to convert a simple JSON string such as {\"Name\":\"abc\", \"age\":10} to the corresponding JSON object (not a custom Scala object such as \"Person\"). D

4条回答
  •  孤城傲影
    2020-12-31 04:17

    You might want to use a library like Spray JSON. It provides a lot of easy to use functionality for converting to and from JSON. If you decide to use Spray JSON you can do this:

    import spray.json._
    // some code here
    val json = "your json string here".parseJson
    

提交回复
热议问题