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

The array #310

Open
flyrlabs-rch opened this issue Jan 27, 2023 · 1 comment
Open

The array #310

flyrlabs-rch opened this issue Jan 27, 2023 · 1 comment

Comments

@flyrlabs-rch
Copy link

this test fails because the length of value.Array() is two instead of the expected 4.

When the length was 1, the length of Array() was 1
When the length was 2, the length of Array() was 1
When the length was 3, the length of Array() was 1
When the length was 4, the length of Array() was 2
When the length was 5, the length of Array() was 3
When the length was 6, the length of Array() was 4

Might this be in arrayOrMap(), where it treats every other element as a key?

func TestArray(t *testing.T) {
	parsed := gjson.Get("{\"foo\" : [\"a\", Null, False, 1]}", "foo")

	assert.Truef(t, parsed.IsArray(), "the array element %v is not reporting IsArray()", parsed)
	assert.Equal(t, 4, len(parsed.Array()))
}

Cheers

@tidwall
Copy link
Owner

tidwall commented Jan 27, 2023

The json that you provided the Get statement looks invalid. The Null and False should be null and false.

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

2 participants