Scala: Parse JSON directly into a case class

后端 未结 7 2238
一生所求
一生所求 2020-12-24 11:36

Given a string of JSON, and a case class that corresponds to it, what\'s a simple way to parse the JSON into the case class? There are many libraries available, but it seem

7条回答
  •  情深已故
    2020-12-24 11:54

    I second the JSON conversion in the Play Framework.

    Also take a look at Jackson which is mature. Note you will need to use Jackson Scala Module : https://github.com/FasterXML/jackson-module-scala.

    A decent article providing an intro - then some code to add implicit conversions : https://coderwall.com/p/o--apg/easy-json-un-marshalling-in-scala-with-jackson

提交回复
热议问题