0

I am trying to use rapture.io Scala JSON parser to parse a JSON value (rows) that looks like this:

{
    rows: 
    [
        [
         null,
         "2016-11-16T15:43:18.000Z",
          {
            "p": 1,
            "q": 2
         },
         null,
         "Game highlights"
        ],
        [
         null,
         "2007-10-09T01:52:29.000Z",
          {
            "p": 21,
            "q": 99
         },
         "blaah",
         "Game reviews"
        ]
}

My code looks like this:

import rapture.io._
import rapture.codec._
import rapture.json._
import rapture.data._
import rapture.uri._
import rapture.net._
import encodings.system
import jsonBackends.jawn._

class NotesDownloader () {

  def download(): Unit = {

    val src = uri"https://some_url".slurp[Char]
    val jsonResponse = Json.parse(src)

    val rows = jsonResponse.data.rows

    val rowsBean = rows(0).as[Array[Member]]
    println(jsonResponse)
  }

  case class Member(array: Array[Some[String]])

}

When I try to extract the complete data into Member, I get this exception:

Error:(40, 30) not enough arguments for method as: (implicit ext: rapture.data.Extractor[Array[NotesDownloader.this.Member],rapture.json.Json], implicit mode:
    rapture.core.Mode[rapture.data.ExtractionMethods])mode.Wrap[Array[NotesDownloader.this.Member],rapture.data.DataGetException].
    Unspecified value parameters ext, mode. val rowsBean = value.as[Array[Member]]

what am I missing?

Darth.Vader
  • 5,079
  • 7
  • 50
  • 90

2 Answers2

0

As long as I know, you could use something like this.

Json.parse(str).as[List[Member]]) since it's a list not an a simple array.

Igor Costa
  • 184
  • 1
  • 8
0

The error message tells you that you need values for the implicit parameters ext and mode. It would be something like this:

implicit val ext = ...
implicit val mode = ...
val rowsBean = rows(0).as[Array[Member]] // this uses the above implicits
radumanolescu
  • 4,059
  • 2
  • 31
  • 44