Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cc: can't resolve alias type as json.Marshal #82

Closed
AsterDY opened this issue Aug 26, 2021 · 0 comments · Fixed by #87
Closed

cc: can't resolve alias type as json.Marshal #82

AsterDY opened this issue Aug 26, 2021 · 0 comments · Fixed by #87
Labels
bug Something isn't working

Comments

@AsterDY
Copy link
Collaborator

AsterDY commented Aug 26, 2021

  • version
    v0.0.0-20210824052355-8c119dd72d11
  • code
type JString string

func (j *JString) UnmarshalJSON(b []byte) error {
	*j = JString(b)
	return nil
}

func (j JString) MarshalJSON() ([]byte, error) {
	return []byte(j), nil
}

type Data []*map[string]JString

var Tstring = "[{\"group_item_0\":\"652900\",\"group_item_1\":23,\"item_count\":1}]"

func TestX(t *testing.T) {
	var Tdata Data
	err := sonic.Unmarshal([]byte(Tstring), &Tdata)
	fmt.Println(err.(decoder.SyntaxError).Description())

	err = json.Unmarshal([]byte(Tstring), &Tdata)
	fmt.Println(err)
}
  • result
Syntax error at index 41: invalid char

	,"group_item_1":23,"item_count":
	................^...............

<nil>
@AsterDY AsterDY added the bug Something isn't working label Aug 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant