[
https://issues.apache.org/jira/browse/THRIFT-5089?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Sylwester Lachiewicz resolved THRIFT-5089.
------------------------------------------
Resolution: Fixed
Generated Go enums implement {{encoding.TextUnmarshaler}}: the generator emits
{{UnmarshalText}}
([t_go_generator.cc|https://github.com/apache/thrift/blob/master/compiler/cpp/src/thrift/generate/t_go_generator.cc]),
and {{encoding/json}} calls it for string values. Verified with a compiler
built from master: {{json.Unmarshal}} of {{{"c":"BLUE"}}} into a struct with an
enum field yields {{BLUE}}, an unknown name fails with {{not a valid Color
string}}, and {{json.Marshal}} writes the name. The method has been in the
generator since 0.10.0 at the latest. Resolving as fixed; reopen if a case is
still missing.
_This comment was created with AI assistance._
> Feature to unmarshall json to structs with enums
> ------------------------------------------------
>
> Key: THRIFT-5089
> URL: https://issues.apache.org/jira/browse/THRIFT-5089
> Project: Thrift
> Issue Type: Improvement
> Components: Go - Compiler
> Affects Versions: 0.13.0
> Reporter: Serhii
> Priority: Major
> Time Spent: 20m
> Remaining Estimate: 0h
>
> Hello.
> Go compiler generate a lot of functions, but he didn't generate UnmashalJSON
> for ENUM. This PR provides functionality for this.
> https://github.com/apache/thrift/pull/2004
--
This message was sent by Atlassian Jira
(v8.20.10#820010)