propensive / rapture

Rapture
183 stars 39 forks source link

the key String("xxx") is not in the dictionary #273

Closed wiradikusuma closed 6 years ago

wiradikusuma commented 7 years ago

The following snippet does not show any error in IntelliJ:

import rapture.json._
import rapture.json.jsonBackends.jawn._

val data = Json.parse(fromInputStream(req.getInputStream).mkString)

if (data.foo.as[String] == "bar")
    data.entry.as[Vector[Json]].foreach { ... }

But when I run it from Gradle, it throws error:

the key String("foo") is not in the dictionary
the key String("entry") is not in the dictionary

What do I miss?

tumakha commented 7 years ago

The same exception with version "rapture_2.11" % "2.0.0-M9"

winstonjr commented 7 years ago

I was saying that the version is "rapture_2.12" "2.0.0-M9". The version 2.0.0-M8 works properly. No error for this.

mnd999 commented 6 years ago

You need some completely undocumented magic:

import rapture.json.dictionaries.dynamic._

propensive commented 6 years ago

Well done for finding that, @mnd999. Sorry it was thrown in there with so little explanation. Alternatively you can define an implicit "dictionary" of labels if you want to only allow a subset of strings to be usable as accessors for JSON values.

propensive commented 6 years ago

Note that I'm no longer maintaining Rapture, but I intend to pull some of the best parts out into new projects.