just use json.Number
This commit is contained in:
parent
1ea8a24224
commit
7f499012a6
2 changed files with 1 additions and 11 deletions
|
@ -4,7 +4,6 @@ package common
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
@ -13,17 +12,8 @@ type (
|
|||
// PyTimeStamp is a python-style long nano timestamp
|
||||
PyTimestamp time.Time
|
||||
|
||||
// KeepZero is a special float that keeps the trailing zero on marshal
|
||||
KeepZero float64
|
||||
)
|
||||
|
||||
func (f KeepZero) MarshalJSON() ([]byte, error) {
|
||||
if float64(f) == float64(int(f)) {
|
||||
return []byte(strconv.FormatFloat(float64(f), 'f', 1, 32)), nil
|
||||
}
|
||||
return []byte(strconv.FormatFloat(float64(f), 'f', -1, 32)), nil
|
||||
}
|
||||
|
||||
const PytTimeFormat = "2006-01-02T15:04:05.999999-07:00"
|
||||
|
||||
func (t *PyTimestamp) MarshalJSON() ([]byte, error) {
|
||||
|
|
|
@ -25,7 +25,7 @@ type RefreshToken struct {
|
|||
ClientIcon *string `json:"client_icon"`
|
||||
TokenType TokenType `json:"token_type"`
|
||||
CreatedAt *common.PyTimestamp `json:"created_at"`
|
||||
AccessTokenExpiration common.KeepZero `json:"access_token_expiration"`
|
||||
AccessTokenExpiration json.Number `json:"access_token_expiration"`
|
||||
Token string `json:"token"`
|
||||
JWTKey string `json:"jwt_key"`
|
||||
LastUsedAt *common.PyTimestamp `json:"last_used_at"`
|
||||
|
|
Loading…
Reference in a new issue