错误: jsoniter.UnmarshalFromString
作者: ydg941020创建于 2025年11月17日更新于 2025年11月17日
func Test_json(t *testing.T) {
res := &TextStyle{}
style := {"isBold": 0, "fontSize": 136, "isItalic": 0, "fontStyle": "", "textAlign": "center", "textColor": "rgba(0,0,0,1)", "fontFamily": "ABeeZee-regular"}
_ = jsoniter.UnmarshalFromString(style, res)
t.Logf("res=%+v", res) // res=&{FontFamily: FontSize:36 TextAlign: TextColor: FontStyle: IsBold:false IsItalic:false Underline:}
_ = json.Unmarshal([]byte(style), res)
t.Logf("res=%+v", res) // res=&{FontFamily:ABeeZee-regular FontSize:136 TextAlign:center TextColor:rgba(0,0,0,1) FontStyle: IsBold:false IsItalic:false Underline:}
}
内容来源: json-iterator/go