package domain import ( "encoding/json" "strings" ) // Storage discriminators are stable so historical completion scopes stay valid. // The API exposes only the current hierarchy vocabulary. func (k ExamPrepParentKind) MarshalJSON() ([]byte, error) { value := string(k) switch k { case ExamPrepParentKindUnit: value = "CHAPTER" case ExamPrepParentKindCatalogCourse: value = "COURSE" } return json.Marshal(value) } func (k *ExamPrepParentKind) UnmarshalJSON(data []byte) error { var value string if err := json.Unmarshal(data, &value); err != nil { return err } value = strings.ToUpper(strings.TrimSpace(value)) switch value { case "CHAPTER": value = "UNIT" case "COURSE": value = "CATALOG_COURSE" } *k = ExamPrepParentKind(value) return nil }