Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-4011

Sets of Thrift structs generate Go code that can't be serialized to JSON

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 0.11.0
    • Go - Compiler
    • None

    Description

      Consider the following structs:

      struct Foo {
        1: optional string foo
      }
      
      struct Bar {
        1: optional set<Foo> foos
      }
      

      This compiles into the following Go code:

      type Bar struct {
      	Foos map[*Foo]struct{} `thrift:"foos,1" db:"foos" json:"foos,omitempty"`
      }
      

      Even though the generated code has tags for JSON support, Bar can't be serialized to JSON:

      json: unsupported type: map[*Foo]struct {}
      

      One solution would be to use slices, not maps, for Thrift sets. Thoughts?

      Attachments

        Issue Links

          Activity

            People

              dcelasun Duru Can Celasun
              dcelasun Duru Can Celasun
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: