3
0

Allow paging cursor to decode string when needed

This commit is contained in:
Tomaž Jerman
2021-08-30 19:24:35 +02:00
parent f485c4a3d5
commit b73a76263c
+11
View File
@@ -200,8 +200,19 @@ func (p *PagingCursor) UnmarshalJSON(in []byte) error {
R bool
LT bool
}
err error
)
// Decode the the string if it's not a JSON
if in[0] != byte('{') {
s := string(in)
in, err = base64.StdEncoding.DecodeString(s[1 : len(s)-1])
if err != nil {
return err
}
}
if err := json.Unmarshal(in, &aux); err != nil {
return err
}