json_tag
Types
Values
pub fn decode(
from json: dynamic.Dynamic,
) -> Result(#(String, dynamic.Dynamic), List(decode.DecodeError))
Decodes a tagged JSON dynamic value, extracting the #type tag
and returning the tag value with the original dynamic for further
field decoding.
pub fn encode(
tag tag: String,
fields fields: List(#(String, json.Json)),
) -> json.Json
Encodes a tagged JSON object with #type set to the given tag.
encode(tag: "Circle", fields: [#("radius", json.float(4.0))])
|> json.to_string()
// {"#type":"Circle","radius":4.0}
pub fn tag_of(
from json: dynamic.Dynamic,
) -> Result(String, List(decode.DecodeError))
Extracts just the #type tag value from a dynamic JSON value.