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

unmarshal from 2d array string to 1d array will return no error #662

Open
horsdy opened this issue Mar 3, 2023 · 0 comments
Open

unmarshal from 2d array string to 1d array will return no error #662

horsdy opened this issue Mar 3, 2023 · 0 comments

Comments

@horsdy
Copy link

horsdy commented Mar 3, 2023

OS: window 10
go version: go1.19 windows/amd64
json-iterator: v1.1.12
purpose:unmarshal from 2d array string to 1d array and error will return

type Person struct {
	Age  int64  `json:"age"`
	Name string `json:"name"`
}

func TestAnything3(t *testing.T) {
	var s = `[
		[
			{
				"age": 1,
				"name": "jack"
			}
		]
	]`
	var ps []*Person
	err := jsoniter.Unmarshal([]byte(s), &ps)
	fmt.Printf("ps: len:%v\n", len(ps))
	fmt.Printf("ps: value:\n")
	for k, v := range ps {
		fmt.Printf("k:%v, v:%v\n", k, v)
	}
	fmt.Printf("err: %v\n", err)
}

result:
=== RUN TestAnything3
ps: len:1
ps: value:
k:0, v:&{0 }
err: nil
--- PASS: TestAnything3 (0.00s)
PASS

err should not be nil

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant