Current section
Files
Jump to
Current section
Files
src/example@codecs.erl
-module(example@codecs).
-compile(no_auto_import).
-export([json_of_language/1, json_of_country/1, json_of_city/1]).
-spec json_of_language(example@store:language()) -> gleam@json:json().
json_of_language(Language) ->
gleam@json:object(
[{<<"code"/utf8>>, gleam@json:string(erlang:element(2, Language))},
{<<"name"/utf8>>, gleam@json:string(erlang:element(3, Language))}]
).
-spec json_of_country(example@store:country()) -> gleam@json:json().
json_of_country(Country) ->
gleam@json:object(
[{<<"code"/utf8>>, gleam@json:string(erlang:element(2, Country))},
{<<"name"/utf8>>, gleam@json:string(erlang:element(3, Country))}]
).
-spec json_of_city(example@store:city()) -> gleam@json:json().
json_of_city(City) ->
gleam@json:object(
[{<<"name"/utf8>>, gleam@json:string(erlang:element(2, City))}]
).