JacksonSource

Provides helpers for creating fs2.Stream and Iterator instances of JsonEvent from various underlying event sources, using the Jackson library as the underlying event parser.

The helpers in this object operate in terms of the IntoJacksonJsonParser typeclass, which defines logic for using a source value to construct a Jackson JsonParser in a Resource. From there, the helpers take care of converting the jackson parser/event model to the spac JsonEvent model.

For example:

  val file = new File("./stuff.json")
  val jsonStream: Stream[IO, JsonEvent] = JacksonSource[IO](file)
class Object
trait Matchable
class Any

Value members

Concrete methods

def apply(jacksonParser: JsonParser): Source[JsonEvent]

Wrap an existing Jackson JsonParser as a single-use source of JsonEvents.

Wrap an existing Jackson JsonParser as a single-use source of JsonEvents.

The source will not attempt to close the underlying parser.

Value parameters:
jacksonParser

A Jackson JsonParser

Returns:

A single-use JSON event source

def fromFile(file: File, factory: JsonFactory): Source[JsonEvent]

Creates a new Source that reads JsonEvents from the given file.

Creates a new Source that reads JsonEvents from the given file.

Value parameters:
factory

A Jackson JsonFactory used to construct the underlying JsonParser for the string

file

A JSON file

Returns:

A reusable JSON event source

def fromInputStream(stream: InputStream, factory: JsonFactory): Source[JsonEvent]

Wrap an InputStream as a single-use source of JsonEvents.

Wrap an InputStream as a single-use source of JsonEvents.

The Source will not attempt to close the input stream.

Value parameters:
factory

A Jackson JsonFactory used to construct the underlying JsonParser for the string

stream

An InputStream over raw JSON bytes

Returns:

A single-use JSON event source

def fromReader(reader: Reader, factory: JsonFactory): Source[JsonEvent]

Wrap a Reader as a single-use source of JsonEvents.

Wrap a Reader as a single-use source of JsonEvents.

The Source will not attempt to close the reader.

Value parameters:
factory

A Jackson JsonFactory used to construct the underlying JsonParser for the string

reader

A Reader over characters of raw JSON

Returns:

A single-use JSON event source

def fromString(rawJson: String, factory: JsonFactory): Source[JsonEvent]

Wrap a string of raw JSON as a source of JsonEvents

Wrap a string of raw JSON as a source of JsonEvents

Value parameters:
factory

A Jackson JsonFactory used to construct the underlying JsonParser for the string

rawJson

A string containing raw JSON

Returns:

A reusable JSON event source

Concrete fields

lazy val defaultFactory: JsonFactory

Default JsonFactory used by the helpers in this object when interfacing with the IntoJacksonJsonParser typeclass to create the underlying Jackson JsonParsers.

Default JsonFactory used by the helpers in this object when interfacing with the IntoJacksonJsonParser typeclass to create the underlying Jackson JsonParsers.

This is a new JsonFactory with no additional modifications.