feat(job): add support for _parsed_params job field

This commit is contained in:
2022-12-11 20:58:50 +00:00
parent 269cb8586e
commit 118b9115b0
2 changed files with 107 additions and 39 deletions

37
algorithm_version.go Normal file
View File

@@ -0,0 +1,37 @@
package midjourney
import (
"encoding/json"
"strconv"
)
type AlgorithmVersion string
func (av *AlgorithmVersion) MarshalJSON() ([]byte, error) {
n, err := strconv.Atoi(string(*av))
if err != nil {
return json.Marshal(string(*av))
}
return json.Marshal(n)
}
func (av *AlgorithmVersion) UnmarshalJSON(b []byte) error {
var n int
err := json.Unmarshal(b, &n)
if err == nil {
*av = AlgorithmVersion(strconv.Itoa(n))
return nil
}
var s string
err = json.Unmarshal(b, &s)
if err == nil {
*av = AlgorithmVersion(s)
return nil
}
return err
}