Skip to content
This repository was archived by the owner on Dec 15, 2025. It is now read-only.

Bug: jsoniter.UnmarshalFromString #717

@ydg941020

Description

@ydg941020
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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions