```erlang
to_json (Bin, Format) when is_binary (Bin) ->
  from_binary (Bin, Format);
to_json (Event = #lwes_event {name = Name}, json_typed_eep18) ->
  { [ { <<"name">>, Name } | export_attributes (typed, Event) ] };
to_json (Event = #lwes_event {name = Name}, json_typed_string) ->
  lwes_mochijson2:encode (to_json(Event, json_type_eep18));
...
```