I'm trying to figure out the way how to write json to archive file/stream.
Try {
val baos = new ByteArrayOutputStream
val zos = new ZipOutputStream(baos)
series.foreach { s =>
val entry = new ZipEntry(s"${s.timeseries}.json")
zos.putNextEntry(entry)
zos.write(s.asJson.toString().getBytes)
zos.closeEntry()
zos.close()
}
baos
}
I feel like this is the wrong way to do it: data.asJson.toString().getBytes