feat(Carbon): 添加空值处理

- 在 UnmarshalJSON 方法中增加空值判断
- 设置 isEmpty 标志以表示空值情况
This commit is contained in:
gouguoyin
2025-09-16 11:07:42 +08:00
parent d938246cc2
commit 862ef2b205

View File

@@ -55,6 +55,7 @@ func (c Carbon) MarshalJSON() ([]byte, error) {
func (c *Carbon) UnmarshalJSON(src []byte) error {
v := string(bytes.Trim(src, `"`))
if v == "" || v == "null" {
c.isEmpty = true
return nil
}
*c = *ParseByLayout(v, DefaultLayout)