mirror of
https://github.com/yusing/godoxy.git
synced 2025-06-15 06:26:47 +02:00
refactor: simplify JSON marshaling in withSubject by using a map
This commit is contained in:
parent
477ddb6241
commit
864a43266d
1 changed files with 4 additions and 7 deletions
|
@ -93,13 +93,10 @@ func (err *withSubject) MarshalJSON() ([]byte, error) {
|
|||
for i, s := range err.Subjects {
|
||||
subjects[len(err.Subjects)-i-1] = s
|
||||
}
|
||||
reversed := struct {
|
||||
Subjects []string `json:"subjects"`
|
||||
Err error `json:"err"`
|
||||
}{
|
||||
Subjects: subjects,
|
||||
Err: err.Err,
|
||||
}
|
||||
|
||||
reversed := map[string]any{
|
||||
"subjects": subjects,
|
||||
"err": err.Err,
|
||||
}
|
||||
return json.Marshal(reversed)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue