Last active
March 30, 2021 12:24
-
-
Save Yotamho/49b3b13db8d1bf931a3aed8daff7f8a8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.typelevel.jawn._ | |
| import org.typelevel.jawn.ast.JValue | |
| object JawnChunkParsing { | |
| val parser = AsyncParser[JValue](AsyncParser.ValueStream) | |
| fs2.Stream.emits( | |
| """ | |
| |{"adiel": "isGever", "yotam": 1111} | |
| |{"adiel": "blahblah", "yotam": -14} | |
| |{"adiel": "nahanaha", "yotam": 0} | |
| |""".stripMargin).map(_.toByte) | |
| .chunks | |
| .flatMap(c => parser.absorb(c.toBytes.values) match { | |
| case Right(js) => fs2.Stream.emits(js) | |
| case Left(e) => fs2.Stream.raiseError(e) | |
| }) | |
| parser.finish() | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment