[ 
https://issues.apache.org/jira/browse/THRIFT-4011?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15854483#comment-15854483
 ] 

James E. King, III commented on THRIFT-4011:
--------------------------------------------

This was described as a breaking change.  I am doing something similar for 
perl, switching the type for a set to Set::Scalar.  I want to remain backwards 
compatible as an option while having the new behavior the default, and I was 
going to add a compiler option like {{--gen perl:hash_sets}} to make it use 
hashes like it always has.  Do we need a go compiler option here to emit 
backwards-compatible or new code here depending?

> Sets of Thrift structs generate Go code that can't be serialized to JSON
> ------------------------------------------------------------------------
>
>                 Key: THRIFT-4011
>                 URL: https://issues.apache.org/jira/browse/THRIFT-4011
>             Project: Thrift
>          Issue Type: Bug
>          Components: Go - Compiler
>            Reporter: Can Celasun
>
> Consider the following structs:
> {code}
> struct Foo {
>   1: optional string foo
> }
> struct Bar {
>   1: optional set<Foo> foos
> }
> {code}
> This compiles into the following Go code:
> {code}
> type Bar struct {
>       Foos map[*Foo]struct{} `thrift:"foos,1" db:"foos" json:"foos,omitempty"`
> }
> {code}
> Even though the generated code has tags for JSON support, Bar can't be 
> serialized to JSON:
> {code}
> json: unsupported type: map[*Foo]struct {}
> {code}
> One solution would be to use slices, not maps, for Thrift sets. Thoughts?



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to