File tree Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Expand file tree Collapse file tree 2 files changed +32
-2
lines changed Original file line number Diff line number Diff line change 1
1
package brood
2
2
3
+ import (
4
+ "encoding/json"
5
+ )
6
+
3
7
type User struct {
4
8
Id string `json:"id"`
5
9
Username string `json:"username"`
@@ -83,11 +87,37 @@ type resourceUpdateRequest struct {
83
87
}
84
88
85
89
type ResourceHolder struct {
86
- Id string `json:"id "`
90
+ Id string `json:"holder_id "`
87
91
HolderType string `json:"holder_type"`
88
92
Permissions []string `json:"permissions"`
89
93
}
90
94
95
+ func (r * ResourceHolder ) UnmarshalJSON (data []byte ) error {
96
+ // Define an alias to avoid recursion in custom unmarshaling
97
+ type Alias ResourceHolder
98
+ aux := & struct {
99
+ Id string `json:"id"`
100
+ HolderId string `json:"holder_id"`
101
+ * Alias
102
+ }{
103
+ Alias : (* Alias )(r ),
104
+ }
105
+
106
+ // Unmarshal into the auxiliary struct
107
+ if err := json .Unmarshal (data , & aux ); err != nil {
108
+ return err
109
+ }
110
+
111
+ // Populate the Id field based on available data
112
+ if aux .Id != "" {
113
+ r .Id = aux .Id
114
+ } else {
115
+ r .Id = aux .HolderId
116
+ }
117
+
118
+ return nil
119
+ }
120
+
91
121
type ResourceHolders struct {
92
122
ResourceId string `json:"resource_id"`
93
123
Holders []ResourceHolder `json:"holders"`
Original file line number Diff line number Diff line change 1
1
package bugout
2
2
3
- const Version string = "0.4.5 "
3
+ const Version string = "0.4.6 "
You can’t perform that action at this time.
0 commit comments