What is a good library for JSON serialization for Scala 2.8.1 for use in Eclipse

蓝咒 提交于 2019-12-07 17:27:05

问题


I have looked at https://github.com/debasishg/sjson and using EGit I was not able to import this code for Scala 2.8.1.

Ideally, this seems to be the best library that should work, but when I loaded master it is currently empty.

I am trying to use Jersey (http://jersey.java.net) to build a REST service in Scala, but the JSON serialization is where I am stuck, as I would prefer to use something written in Scala.

Unfortunately there isn't anything for Scala at http://json.org/.

So, how do I import SJSON for use in Scala 2.8.1, for Eclipse, or, is there a more updated library that would work as well?


回答1:


If you look at the fork graph of that repo, you will see ginkel's version of sjson with:

  • a non-empty master branch (note: debasishg's master branch isn't empty as well)
  • 2.8.1. settings for the sbt build parameters.



回答2:


Lift JSON has prebuilt 2.8.1 compatible versions at:

http://scala-tools.org/repo-releases/net/liftweb/lift-json_2.8.1/

Please see "Installation" from:

https://github.com/lift/lift/tree/master/framework/lift-base/lift-json




回答3:


Writing REST services with Jersey (in Java) is what I do every day at work. I use the integration Jersey has with Jackson for JSON serialization and deserialization. Using another library with Jersey would be swimming upstream. You're using a REST library written in Java, so why not a JSON library in Java too, especially since it just works out of the box?

When I want to write a Scala REST service, I use SBT, the Scalatra web framework and lift-json. It works great.

I don't use Eclipse, but the selection of JSON library is orthogonal to what IDE/editor/etc you use. I would certainly never want to choose a library based on its ability to play nice in Eclipse.

If you're interested in using Scala to write a REST service (very quickly), start with this tutorial: http://blog.everythings-beta.com/?p=430

Add some case classes and lift-json support for parsing them. Excellent examples here: https://github.com/lift/lift/tree/master/framework/lift-base/lift-json/ (scroll down) You can add lift-json to your SBT project with:

val lift_json = "net.liftweb" %% "lift-json" % "2.1"

I've found lift-json excellent for both parsing and generating JSON. But if I'm using Jersey, I use the built in support for Jackson, since it is excellent and there's no reason to use anything else.



来源:https://stackoverflow.com/questions/4577261/what-is-a-good-library-for-json-serialization-for-scala-2-8-1-for-use-in-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!