Hi Pablo,
Instead of extracting a
case class, Rapture lets you extract a JSON value as a `Map[String,
<something>]`, though you need to pick an appropriate
<something>. If all your values were `String`s, then you can
extract `Map[String, String]`, however, if they all have different
types, it would be better to extract `Map[String, Json]`, and to perform
a subsequent extraction on each one. Here's an example:
Say this JSON was posted:
{
"message": "Hello World",
"count": 7
}
If this is stored in a JSON value, `j`, we could get the values out like this:
val jMap =
j.as[Map[String, Json]]
jMap("message").as[String]
jMap("count").as[Int]
This is basically equivalent to using the dynamic types, though, e.g.:
which are also easier to read.
Is
this enough for your purposes? There is another possibility which takes
a bit longer to explain, but would offer the safety that it would only
allow you to access fields with names in your list of 4554 fields, and
you wouldn't need to specify the type each time (but you would need to
provide the list of field names and corresponding types in advance). I
can explain this solution too, if you like.
Cheers,
Jon