cbeust/klaxon

Is there a memory-light way of doing URL -> Flow?

salamanders opened this issue · 0 comments

Without loading the whole text into memory, is there an easy way of

  1. URL: https://mysite.com/mybigflatdoc.json of many, many MyElement in an array
  2. Open an input stream
  3. Without loading the whole thing, return a Flow

I found a way to do it the hacky way in GSON, but I was hoping to move to this library to do it without loading the whole thing!

fun readScript(scriptURL: String): Flow<Point2D> =
    (GSON.fromJson(URL(scriptURL).readTextSupportGZIP(), listOfPointsType) as List<Point2D>)
        .asFlow()