Skip to content
This repository has been archived by the owner on May 21, 2018. It is now read-only.

Problem with Serializers of case classes that contain Map[Int,Int] #238

Open
johannegger opened this issue Sep 19, 2016 · 1 comment
Open

Comments

@johannegger
Copy link

the following code does not compile:


import rapture.json.{Json, _}

case class Foo(value:Map[Int,Int])
case class Bar(foos:Seq[Foo])

class Test(implicit ast:JsonAst) {

  val myBar = Bar(List(Foo(Map(1->1))))
  //implicit val ser = implicitly[Serializer[Foo,Json]]
  Json(myBar)
}

but removing the commented implicit solves the error. The error for scala 2.10 doesn't help much:

Cannot serialize type com.example.Bar to rapture.json.Json. Please provide an implicit Serializer of type com.example.Bar.

However using 2.11 we get:

diverging implicit expansion for type rapture.json.Serializer[com.example.Bar,rapture.json.Json]

this leads me to suspect a problem related to the Map[Int,Int] - Maybe there are different strategies for maps that use keys other than String?

@tyrcho
Copy link

tyrcho commented Feb 19, 2018

I've tried to reproduce your workaround, but without success. Here is my minimalist project:
https://github.com/tyrcho/rapture-json-demo/blob/map/src/main/scala/BiggerDemo.scala

It could be because I'm still in 1.1.0 ... But I cannot migrate to 2.0 because of #278

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants