slackline/value
Free-form json values.
Slack sends free-form json in many places: message metadata, workflow
step outputs, datastore items, and any event or block that slackline does
not know yet. Value holds that data. You can pattern match on it, encode
it again, or run your own decoders on it.
let payload =
value.Object([
#("id", value.String("11223")),
#("title", value.String("Redesign Homepage")),
])
Types
Values
pub fn decode(
value: Value,
decoder: decode.Decoder(a),
) -> Result(a, List(decode.DecodeError))
Runs a decoder on a Value, for example on an unknown event or block:
case event {
event.UnknownEvent(type_: "my_custom_event", raw:) ->
value.decode(raw, my_event_decoder())
_ -> todo
}
pub fn parse(text: String) -> Result(Value, json.DecodeError)
Parses a json string into a Value.
pub fn string_field(
value: Value,
key: String,
) -> Result(String, Nil)
Looks up a string in an object.
pub fn to_dynamic(value: Value) -> dynamic.Dynamic
Converts a Value to Dynamic so it can be fed to a decoder.