How to convert JSON to a type in Scala

后端 未结 5 1856
野性不改
野性不改 2021-02-19 04:06

My problem is I receive an JSON text from say, twitter. Then I want to convert this text to an native object in scala. Is there a standard method to do this? I\'m also using Pla

5条回答
  •  忘掉有多难
    2021-02-19 04:24

    Try Jerkson lib: https://github.com/codahale/jerkson/

    It is a json library for scala based on Jackson. It is included to play 2: http://www.playframework.org/documentation/2.0.2/ScalaJson

    Example:

        case class Person(id: Long, name: String)
        parse[Person]("""{"id":1,"name":"Coda"}""") //=> Person(1,"Coda")
    

提交回复
热议问题