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

Make generated go enums implement TextMarshaller and TextUnmarshaller interfaces

    XMLWordPrintableJSON

    Details

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

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

              Dates

              • Created:
                Updated:
                Resolved: