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

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.11.0
    • Component/s: Go - Compiler
    • Labels:
      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

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

                Dates

                • Created:
                  Updated:
                  Resolved: