JsonBuffer.empty dfoesn't exist in Rapture-json 0.9.0

33 views
Skip to first unread message

Corey Nolet

unread,
Nov 26, 2014, 1:17:59 PM11/26/14
to raptur...@googlegroups.com
I'm kind of forced to use version 0.9.0 at the moment and the JsonBuffer doesn't appear to have the empty method on it for construction. I'm somewhat new to Scala but I don't see an easy way to construct the JsonBuffer.

Jon Pretty

unread,
Nov 26, 2014, 1:59:56 PM11/26/14
to raptur...@googlegroups.com
Hi Corey,

I'd urge you to upgrade to the latest version as soon as you can! There are several issues in the 0.9.x versions, and it's not maintained any more...

But nevertheless, the best way to start is probably to parse an empty object, like this:

   val jb = JsonBuffer.parse("{}")

As you probably know, you can use `JsonBuffer.empty` in later versions. ;)

Cheers,
Jon

On 26 November 2014 at 18:17, Corey Nolet <cjn...@gmail.com> wrote:
I'm kind of forced to use version 0.9.0 at the moment and the JsonBuffer doesn't appear to have the empty method on it for construction. I'm somewhat new to Scala but I don't see an easy way to construct the JsonBuffer.

--
You received this message because you are subscribed to the Google Groups "Rapture users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rapture-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Jon Pretty | @propensive

Corey Nolet

unread,
Nov 26, 2014, 2:10:33 PM11/26/14
to raptur...@googlegroups.com
Jon,

Thanks for the quick response! I seemed to be going down a rabbit hole of bad implicit evidence. Trying to do JsonBuffer.parse("{}") was giving me 2 errors. one of them was about the parse() method needing two different arguments and the other was about JsonBufferParser[S] not being able to determine S.

Jon Pretty

unread,
Nov 26, 2014, 2:18:43 PM11/26/14
to raptur...@googlegroups.com
Could you copy/paste the exact errors?

The following worked for me in the REPL with v0.9.0:

scala> import rapture.core._
import rapture.core._

scala> import rapture.json._
import rapture.json._

scala> import jsonParsers.scalaJson._
import jsonParsers.scalaJson._

scala> import strategy.throwExceptions
import strategy.throwExceptions

scala> JsonBuffer.parse("{}")
{

}

You could also try writing `new JsonBuffer(Array(Map()))` which constructs an empty `JsonBuffer` "natively", but that's a really ugly solution...

(All this is much nicer in version 1.0.0+ ;) )

Cheers,
Jon

Corey Nolet

unread,
Nov 26, 2014, 2:20:42 PM11/26/14
to raptur...@googlegroups.com
First compile error: "Could not find implicit value for evidence parameter of type rapture.json.JsonBufferParser[String]"

Second compile error: "Not enough arguments for method parse"

Corey Nolet

unread,
Nov 26, 2014, 2:26:39 PM11/26/14
to raptur...@googlegroups.com
That worked for me with scalaJson. I'd like to use Jackson underneath, though.

import jsonParsers.jackson._ seems to be where things get confused.

Jon Pretty

unread,
Nov 26, 2014, 2:33:34 PM11/26/14
to raptur...@googlegroups.com
Aha! Sorry, I didn't realise you were using Jackson! Rapture doesn't actually support mutable JSON, which is what the first compile error is trying to say. I can't remember the exact situation for version 0.9.0, but all the other backend implementations do support mutable JSON. But for version 0.9.0, there weren't nearly as many of them, unfortunately.

I think I'm going to have to say I can't do this for the 0.9.0 version. Is there any reason you can't upgrade to the latest version? Let me know if there's anything I can help with.

Cheers,
Jon


Reply all
Reply to author
Forward
0 new messages