Astarte.Flow.Blocks.JsonMapper (astarte_flow v0.1.0)

This is a map block that takes data from incoming Message and makes a Message having a JSON serialized payload. The subtype of the message is set to "application/json" and the type is :binary.

Link to this section Summary

Functions

Starts the JsonMapper.

Makes a new Message with JSON serialzed data, :binary type and "application/json" subtype.

Link to this section Functions

Link to this function

start_link(opts)

@spec start_link([Astarte.Flow.Blocks.JsonMapper.Config.option()]) ::
  GenServer.on_start()

Starts the JsonMapper.

options

Options

  • :pretty - serialize the output to pretty format that is easier to read for humans.
  • :template - a JSONTemplate applied right before serialization.
Link to this function

to_json(msg, config)

@spec to_json(Astarte.Flow.Message.t(), Astarte.Flow.Blocks.JsonMapper.Config.t()) ::
  {:ok, Astarte.Flow.Message.t()} | {:error, any()}

Makes a new Message with JSON serialzed data, :binary type and "application/json" subtype.