jawn-fs2


License

License

GroupId

GroupId

org.http4s
ArtifactId

ArtifactId

jawn-fs2_2.12
Last Version

Last Version

2.0.0-M1
Release Date

Release Date

Type

Type

jar
Description

Description

jawn-fs2
jawn-fs2
Project URL

Project URL

https://github.com/http4s/jawn-fs2
Project Organization

Project Organization

org.http4s
Source Code Management

Source Code Management

https://github.com/http4s/jawn-fs2

Download jawn-fs2_2.12

How to add to project

<!-- https://jarcasting.com/artifacts/org.http4s/jawn-fs2_2.12/ -->
<dependency>
    <groupId>org.http4s</groupId>
    <artifactId>jawn-fs2_2.12</artifactId>
    <version>2.0.0-M1</version>
</dependency>
// https://jarcasting.com/artifacts/org.http4s/jawn-fs2_2.12/
implementation 'org.http4s:jawn-fs2_2.12:2.0.0-M1'
// https://jarcasting.com/artifacts/org.http4s/jawn-fs2_2.12/
implementation ("org.http4s:jawn-fs2_2.12:2.0.0-M1")
'org.http4s:jawn-fs2_2.12:jar:2.0.0-M1'
<dependency org="org.http4s" name="jawn-fs2_2.12" rev="2.0.0-M1">
  <artifact name="jawn-fs2_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.http4s', module='jawn-fs2_2.12', version='2.0.0-M1')
)
libraryDependencies += "org.http4s" % "jawn-fs2_2.12" % "2.0.0-M1"
[org.http4s/jawn-fs2_2.12 "2.0.0-M1"]

Dependencies

compile (3)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.12
org.typelevel : jawn-parser_2.12 jar 1.0.1
co.fs2 : fs2-core_2.12 jar 3.0.0-M3

test (3)

Group / Artifact Type Version
org.typelevel : jawn-ast_2.12 jar 1.0.1
co.fs2 : fs2-io_2.12 jar 3.0.0-M3
org.specs2 : specs2-core_2.12 jar 4.10.5

Project Modules

There are no modules declared in this project.

jawn-fs2 Build Status Maven Central

Asynchronously parse fs2 streams to JSON values with jawn.

Example

sbt test:run to see it in action:

package com.example

import cats.effect.{IO, IOApp, ExitCode}
import fs2.{io, text, Stream}
import fs2.io.file.Files
import java.nio.file.Paths
import jawnfs2._
import scala.concurrent.duration._

object Example extends IOApp {
  // Pick your favorite supported AST (e.g., json4s, argonaut, etc.)
  implicit val facade = org.typelevel.jawn.ast.JawnFacade

  def run(args: List[String]) = {
    // From JSON on disk
    val jsonStream = Files[IO].readAll(Paths.get("testdata/random.json"), 64)
    // Simulate lag between chunks
    val lag = Stream.awakeEvery[IO](100.millis)
    val laggedStream = jsonStream.chunks.zipWith(lag)((chunk, _) => chunk)
    // Print each element of the JSON array as we read it
    val json = laggedStream.unwrapJsonArray
      .map(_.toString)
      .intersperse("\n")
      .through(text.utf8Encode)
    // run converts the stream into an IO, unsafeRunSync executes the IO for its effects
    json.through(io.stdout).compile.drain.as(ExitCode.Success)
  }
}

Migration note

In jawn-fs2-2.x, the root package changes from jawn.fs2 to org.typelevel.jawn.fs2.

Add jawn-fs2 to your project

Add to your build.sbt:

// For cats-effect-2
libraryDependencies += "org.http4s" %% "jawn-fs2" % "1.0.0"

// For cats-effect-3
libraryDependencies += "org.typelevel" %% "jawn-fs2" % "2.0.0-M2"

// Pick your AST: https://github.com/non/jawn#supporting-external-asts-with-jawn
libraryDependencies += "org.typelevel" %% "jawn-ast" % "1.0.0"

Compatibility matrix

Stream Library You need... Status
fs2-3.x "org.typelevel" %% "jawn-fs2" % "2.0.0-M2" milestone
fs2-2.x "org.http4s" %% "jawn-fs2" % "1.0.0" stable
fs2-1.x "org.http4s" %% "jawn-fs2" % "0.14.2" EOL
fs2-0.10.x "org.http4s" %% "jawn-fs2" % "0.12.2" EOL
fs2-0.9.x "org.http4s" %% "jawn-fs2" % "0.10.1" EOL
scalaz-stream-0.8a "org.http4s" %% "jawn-streamz" % "0.10.1a" EOL
scalaz-stream-0.8.x "org.http4s" %% "jawn-streamz" % "0.10.1" EOL

The legacy scalaz-stream artifacts are on the jawn-streamz branch.

org.http4s

http4s

Versions

Version
2.0.0-M1
1.2.1
1.2.0
1.1.3
1.1.2
1.1.1
1.1.0
1.0.1
1.0.1-RC3
1.0.0
1.0.0-RC2
1.0.0-RC1
0.15.0
0.15.0-M2
0.15.0-M1
0.14.2
0.14.1
0.14.0
0.13.0
0.13.0-RC1
0.13.0-M4
0.13.0-M3
0.13.0-M2
0.13.0-M1
0.12.2
0.12.1
0.12.0
0.12.0-M7
0.12.0-M6
0.12.0-M5
0.12.0-M4
0.12.0-M3
0.12.0-M2
0.12.0-M1
0.11.0-M1
0.10.1