Fix JSON unmarshalling in CustomTime types to correctly handle escaped quotes
All checks were successful
Golan Testing / testing (1.24.x, ubuntu-latest) (push) Successful in 25s
All checks were successful
Golan Testing / testing (1.24.x, ubuntu-latest) (push) Successful in 25s
This commit is contained in:
@ -497,7 +497,7 @@ type CustomTime1 struct {
|
|||||||
func (ct *CustomTime1) UnmarshalJSON(b []byte) (err error) {
|
func (ct *CustomTime1) UnmarshalJSON(b []byte) (err error) {
|
||||||
// Use the correct layout string for the desired format
|
// Use the correct layout string for the desired format
|
||||||
const layout = "2006-01-02T15:04:05"
|
const layout = "2006-01-02T15:04:05"
|
||||||
s := strings.Trim(string(b), `\\"`) // Remove surrounding quotes
|
s := strings.Trim(string(b), "\\\"") // Remove surrounding quotes
|
||||||
if s == "null" {
|
if s == "null" {
|
||||||
ct.Time = time.Time{}
|
ct.Time = time.Time{}
|
||||||
return nil
|
return nil
|
||||||
@ -515,7 +515,7 @@ type CustomTime2 struct {
|
|||||||
func (ct *CustomTime2) UnmarshalJSON(b []byte) (err error) {
|
func (ct *CustomTime2) UnmarshalJSON(b []byte) (err error) {
|
||||||
// Use the correct layout string for the desired format
|
// Use the correct layout string for the desired format
|
||||||
const layout = "2006-01-02T15:04:05-0700"
|
const layout = "2006-01-02T15:04:05-0700"
|
||||||
s := strings.Trim(string(b), `\\"`) // Remove surrounding quotes
|
s := strings.Trim(string(b), "\\\"") // Remove surrounding quotes
|
||||||
if s == "null" {
|
if s == "null" {
|
||||||
ct.Time = time.Time{}
|
ct.Time = time.Time{}
|
||||||
return nil
|
return nil
|
||||||
|
Reference in New Issue
Block a user