agemooij / riak-scala-client

An easy to use, non-blocking, fast Scala client library for interacting with Riak.
http://riak.scalapenos.com/
Apache License 2.0
84 stars 24 forks source link

In `LowPriorityDefaultRiakSerializerImplicits` change `T: RootJsonWriter` to `T: RootWriter` #17

Closed hseeberger closed 11 years ago

hseeberger commented 11 years ago

In LowPriorityDefaultRiakSerializerImplicits:

  implicit def sprayJsonSerializer[T: RootJsonWriter] = new SprayJsonSerializer[T]

Do you really need a RootJsonWriter? Wouldn't a JsonWriter suffice?

I ran into an issue, because I like to annotate my public members:

object User extends DefaultJsonProtocol {

  implicit val userFormat: JsonFormat[User] =
    jsonFormat2(User.apply)
}

Only when deleting the type annotation or changing it to RootJsonFormat my code compiled.

agemooij commented 11 years ago

Well, my experience tells me that in most cases you'd like to generate actual valid JSON instead of potentially generating fragments containing raw values without an object or array around them. The purpose of RootJsonFormat is to ensure you only produce valid top-level JSON documents.

I only ever use JsonFormat for non-toplevel field values that serialize to a single value, like dates, timestamps, etc.

Does this argument make sense to you or do you think the client library should not enforce this?

hseeberger commented 11 years ago

Ah, you're right. Thanks!