jsonscalacirce

Parse \n separated json with circe


do you guys know how to parse an array of json objects but without square brackets

{ "jsonValue1": "val1", "jsonValue2": [1, 1, 2, 2]}
{ "jsonValue1": "val1", "jsonValue2": [1, 1, 2, 2]}
{ "jsonValue1": "val1", "jsonValue2": [1, 1, 2, 2]}

to a List[MyScalaType]

case class MyScalaType(jsonValue1: String, jsonValue2: List[Int])

regular parsing to such List returns: error Malformed message body: Invalid JSON


Solution

  • well, thanks to Luis Miguel Mejía Suárez with "io.circe" %% "circe-fs2" i was able to parse such json

    here is short overview. i'm using http4s client

    client.get(uri)(
       _.bodyText
        .through(stringStreamParser)
        .through(decoder[F, MyScalaType])
        .compile
        .toList
    )