Map
extractor typeclass for JSON is missing
#41
Comments
You're right: the extractor was there, but not resolved. I also eventually made it work defining the implicit manually: import rapture.json._
import rapture.json.jsonBackends.argonaut._
implicit def me: Extractor[Map[String, Json], Json] = GeneralExtractors.mapExtractor
json"""{"bool" : true, "int": 3, "string": "bam", "float":0.33, "obj": {"x": 1} }""".as[Map[String, Json]]
res0: scala.collection.immutable.Map[String,rapture.json.Json] = Map(float -> 0.33, obj -> {"x":1}, string -> "bam", bool -> true, int -> 3)
I noticed that my implicit def does not work if I omit the type declaration: implicit def me = GeneralExtractors.mapExtractor // won't resolve! Seems like the return type of the mapExtractor Is this one of those type-inference fuck-up bug you talk about at conferences? :) One more lead: IntelliJ would infer the type: |
Sorry @sscarduzio - I only just saw your response! Thanks for the fix! I've seen that sort of type inference issue several times before, though I don't think it's a bug. In your example |
I've just fixed this, and added another nice feature: If your JSON object keys are all some non-string type, e.g. integers:
and a string parser for those types exists in Rapture, then it's possible to extract directly into that kind of map, i.e.
|
Thanks Jon for the explanation (makes sense now). Although I made it work On Fri, Jan 29, 2016 at 12:25 AM, Jon Pretty notifications@github.com
|
Yep, it should never have gone away! |
This code,
does not compile, because the typeclass instance
Extractor[Map[String, String], Json]
can't be found. An implementation exists inrapture.data
, but it doesn't get resolved.The text was updated successfully, but these errors were encountered: