2

I had a problem with the first version of SJSON (What is a good library for JSON serialization for Scala 2.8.1 for use in Eclipse) that I tried to use, but with the new version I tried the same problem is still there, so it is something I am not certain how to handle.

This is one example of what I am having problems with, it starts on line 50 at https://github.com/ginkel/sjson/blob/master/src/main/scala/sjson/json/Generic.scala:

  <#list 2..9 as i> 
  <#assign typeParams><#list 1..i as j>T${j}<#if i !=j>,</#if></#list></#assign>

  def asProduct${i}[S, ${typeParams}](<#list 1..i as j>f${j}: String<#if i != j>,</#if></#list>)(apply : (${typeParams}) => S)(unapply : S => Product${i}[${typeParams}])(implicit <#list 1..i as j>bin${j}: Format[T${j}]<#if i != j>,</#if></#list>) = new Format[S]{

I used EGit (http://www.eclipse.org/egit/) to get the code, but when I tried to compile it I get several errors, two of which are:

Description Resource    Path    Location    Type
';' expected but double literal found.  Generic.scala   /sjson/src/main/scala/sjson/json    line 50 Scala Problem
';' expected but '[' found. Generic.scala   /sjson/src/main/scala/sjson/json    line 53 Scala Problem

So, how should I be compiling these so it will work, without going through and fixing the code, as it would seem that that is the wrong approach.

Community
  • 1
  • 1
James Black
  • 41,583
  • 10
  • 86
  • 166
  • did you try to just clone the repo through git, outside of eclipse, and use the sbt settings to compile the project? – VonC Jan 02 '11 at 17:54
  • @VonC - I used EGit, which is an eclipse git plugin, to clone the repository, but I will need to look at using sbt, I guess. – James Black Jan 02 '11 at 20:39

1 Answers1

4

It must be some sort of issue with Eclipse because I just cloned the repo and built it with sbt just fine.

If you want to successfully build this, I suggest you install SBT if you haven't already. It really is almost necessary for doing Scala development. It's easy to integrate with Netbeans and IntelliJ - I don't use Eclipse at all any more, but I imagine it can be done there too by opening a shell or console window and running SBT there.

Once you have SBT "installed" (just a jar and a script - http://code.google.com/p/simple-build-tool/), navigate to the directory you cloned SJSON into. Run 'sbt'. At the sbt prompt run 'update' to get the dependencies. Run 'compile' to build. And you're all set.

If you don't need to build from source but just use the library in a project of yours, it's in the Scala Tools repository: http://scala-tools.org/repo-releases/net/debasishg/sjson_2.8.0/ So you can add it as a dependency in sbt or Maven or Ivy. For SBT, this should work:

val sjson = "net.debasishg" % "sjson_2.8.0" % "0.8"

I haven't personally used this library. lift-json has been working well for me. But sjson does look worth a look. Good luck!

Janx
  • 3,285
  • 3
  • 19
  • 24
  • I used https://github.com/musk/SbtEclipsify#readme to help create the Eclipse project files, and that seems to be working. – James Black Jan 03 '11 at 02:44