This project provides support for using fs2 for streaming JSON parsing and decoding with circe, a Scala library for encoding and decoding JSON to Scala types.
Circe-fs2 provides three pipes to parse your streams of JSONs:
stringParser
converts a stream of String
to a stream of Json
, Circe's representation of JSONs:
import io.circe.fs2._
val stringStream: Stream[Task, String] = ...
val parsedStream: Stream[Task, Json] = stringStream.through(stringParser)
byteParser
converts a stream of Byte
to a stream of Json
:
val byteStream: Stream[Task, Byte] = ...
val parsedStream: Stream[Task, Json] = byteStream.through(byteParser)
byteParserC
converts a chunked stream of Byte
to a stream of Json
:
val chunkedByteStream: Stream[Task, Chunk[Byte]] = ...
val parsedStream: Stream[Task, Json] = chunkedByteStream.through(byteParserC)
Circe-fs2 also comes with a decoder
pipe which, given a Decoder[A]
, produces a
Stream[F[_], Json] => Stream[F[_], A]
pipe.
For example, using Circe's fully automatic derivation:
import io.circe.generic.auto._
case class Foo(a: Int, b: String)
val parsedStream: Stream[Task, Json] = ...
val decodedStream: Stream[Task, Foo] = parsedStream.through(decoder[Task, Foo])
All circe projects support the Typelevel code of conduct and we want all of their channels (Gitter, GitHub, etc.) to be welcoming environments for everyone.
Please see the circe contributors' guide for details on how to submit a pull request.
circe-fs2 is licensed under the Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the License.
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.