Scala: Parse JSON directly into a case class

后端 未结 7 2092
一生所求
一生所求 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 12:16

    There are several frameworks which can exactly do that.

    circe

    Used a lot nowdays. Many great features. Will pull cats in.

    https://circe.github.io/circe/ https://github.com/circe/circe

    JSON4s

    JSON4s is quite mature and supports jackson or a native JSON-Parser. Used it in many projects to replace jerkson.

    https://github.com/json4s/json4s

    play-json

    Can be used without the full play stack. Great support as part of the play project at typesafe.

    http://www.playframework.com/documentation/2.0/ScalaJson

    Scala-Pickling

    A serialization Framework. There is an option to serialize/ and deserialize to JSON.

    https://github.com/scala/pickling

    Spray JSON

    Can searialize and deserialize. Need to know number of arguments for deserialization tough.

    https://github.com/spray/spray-json

    0 讨论(0)
提交回复
热议问题