github.com/coyove/nj@v0.0.0-20221110084952-c7f8db1065c3/typ/marshal.go (about)

     1  package typ
     2  
     3  type MarshalType int
     4  
     5  const (
     6  	MarshalToString MarshalType = iota
     7  	MarshalToStringNonRec
     8  	MarshalToJSON
     9  )
    10  
    11  func (m MarshalType) NoRec() MarshalType {
    12  	if m == MarshalToJSON {
    13  		return m
    14  	}
    15  	return MarshalToStringNonRec
    16  }
    17  
    18  func (m MarshalType) String() string {
    19  	switch m {
    20  	case MarshalToString:
    21  		return "str"
    22  	case MarshalToStringNonRec:
    23  		return "strnorec"
    24  	case MarshalToJSON:
    25  		return "json"
    26  	}
    27  	return "unknown"
    28  }