-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Description
type TextStyle struct {
FontFamily string `json:"fontFamily"`
FontSize int32 `json:"fontSize"`
TextAlign string `json:"textAlign"`
TextColor string `json:"textColor"`
FontStyle string `json:"fontStyle"`
IsBold bool `json:"isBold"`
IsItalic bool `json:"isItalic"`
Underline string `json:"underline"`
}
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:}
}
OutPut:
// res=&{FontFamily: FontSize:36 TextAlign: TextColor: FontStyle: IsBold:false IsItalic:false Underline:}
// res=&{FontFamily:ABeeZee-regular FontSize:136 TextAlign:center TextColor:rgba(0,0,0,1) FontStyle: IsBold:false IsItalic:false Underline:}
Metadata
Metadata
Assignees
Labels
No labels