Skip to content

Commit

Permalink
fix: fix sheet true/false value parse
Browse files Browse the repository at this point in the history
  • Loading branch information
chyroc committed Sep 19, 2023
1 parent 830d6ef commit 1b48422
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion type_sheet_content.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,22 @@ func (r *SheetContent) UnmarshalJSON(bytes []byte) error {
r.Int = &integer
}
return nil
} else if bytes[0] == 't' || bytes[0] == 'f' || bytes[0] == 'T' || bytes[0] == 'F' {
var t = "true"
var f = "false"
if len(bytes) == 4 && strings.ToLower(string(bytes)) == t {
r.String = &t
return nil
} else if len(bytes) == 5 && strings.ToLower(string(bytes)) == f {
r.String = &f
return nil
}
return fmt.Errorf("unsupport sheet bool value")
} else if bytes[0] == 'n' {
if len(bytes) == 4 && string(bytes) == "null" {
return nil
}
return fmt.Errorf("unsupport sheet value")
return fmt.Errorf("unsupport sheet null value")
} else if bytes[0] == '{' {
var obj struct {
Type string `json:"type"`
Expand Down

0 comments on commit 1b48422

Please sign in to comment.