Current section
Files
Jump to
Current section
Files
src/deriv@deriv@example@baz@json.erl
-module(deriv@deriv@example@baz@json).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch]).
-export([encode_baz/1, decoder_baz/0, encode_other/1, decoder_other/0]).
-file("src/deriv/deriv/example/baz/json.gleam", 5).
-spec encode_baz(deriv@example@baz:baz()) -> gleam@json:json().
encode_baz(Value) ->
gleam@json:object(
[{<<"baz"/utf8>>, gleam@json:string(erlang:element(2, Value))}]
).
-file("src/deriv/deriv/example/baz/json.gleam", 11).
-spec decoder_baz() -> decode:decoder(deriv@example@baz:baz()).
decoder_baz() ->
_pipe = decode:into(
begin
decode:parameter(fun(Baz) -> {baz, Baz} end)
end
),
decode:field(_pipe, <<"baz"/utf8>>, {decoder, fun gleam@dynamic:string/1}).
-file("src/deriv/deriv/example/baz/json.gleam", 20).
-spec encode_other(deriv@example@baz:other()) -> gleam@json:json().
encode_other(Value) ->
gleam@json:object(
[{<<"other"/utf8>>, gleam@json:int(erlang:element(2, Value))}]
).
-file("src/deriv/deriv/example/baz/json.gleam", 26).
-spec decoder_other() -> decode:decoder(deriv@example@baz:other()).
decoder_other() ->
_pipe = decode:into(
begin
decode:parameter(fun(Other) -> {other, Other} end)
end
),
decode:field(_pipe, <<"other"/utf8>>, {decoder, fun gleam@dynamic:int/1}).