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

Make generated go enums implement TextMarshaller and TextUnmarshaller interfaces

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.9.2
    • 0.9.3
    • Go - Compiler
    • None

    Description

      This will make JSON encoder/decoders use string representation instead of meaningless numbers.

      The new generated code will looks like:

      func (p TestEnum) MarshalText() ([]byte, error) {
      	return []byte(p.String()), nil
      }
      
      func (p *TestEnum) UnmarshalText(text []byte) error {
      	x, err := TestEnumFromString(string(text))
      	*p = x
      	return err
      }
      

      Attachments

        Activity

          People

            k.shaposhnikov@gmail.com Konstantin Shaposhnikov
            k.shaposhnikov@gmail.com Konstantin Shaposhnikov
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: