You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
But if I use the Protobuf.JSON.to_encodable/1 from :protobuf it correct (lowerCamelCase):
%{"success"=>%{"processedAt"=>...}}
Solution: Instead of using Jason to convert the generated structs, the function Protobuf.JSON.to_encodable/1 should used to convert the struct in a previous step.
Of course, it is possible to use the Twirp.Error stuff, but this is only an example, that in case of oneof definition the Jason encoder should not called direct on the structs, because the oneof attribute uses tuples like {:key, value} to support several options.
The text was updated successfully, but these errors were encountered:
zookzook
changed the title
Support for oneof attributes missing?
Support for oneof attributes missing when using JSON?
Mar 31, 2022
Thank you for this package!
Assume the following protobuf definition:
The elixir struct looks this:
If I create new
Result
:An error is returned from the RPC if I use JSON as output format:
But if I use the
Protobuf.JSON.to_encodable/1
from:protobuf
it correct (lowerCamelCase):Solution: Instead of using Jason to convert the generated structs, the function
Protobuf.JSON.to_encodable/1
should used to convert the struct in a previous step.Of course, it is possible to use the
Twirp.Error
stuff, but this is only an example, that in case ofoneof
definition the Jason encoder should not called direct on the structs, because theoneof
attribute uses tuples like{:key, value}
to support several options.The text was updated successfully, but these errors were encountered: