Skip to content
New issue

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

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

Already on GitHub? # to your account

Get fails to return correct result #116

Closed
sheerun opened this issue Aug 22, 2017 · 3 comments
Closed

Get fails to return correct result #116

sheerun opened this issue Aug 22, 2017 · 3 comments

Comments

@sheerun
Copy link

sheerun commented Aug 22, 2017

Not sure what is going on, but Get doesn't work for such simple JSON:

package main

import (
	"fmt"

	"github.com/buger/jsonparser"
)

func main() {
	json := []byte(`{"fiz":"fuz","foo":{"bar":"baz"}}`)

	value, _, _, err := jsonparser.Get(json, "fiz", "bar")

	if err != nil {
		panic(err)
	}

	fmt.Println(string(value))
	// baz
}

It should return an error instead

sheerun added a commit to sheerun/yson that referenced this issue Aug 22, 2017
@JoshuaC215
Copy link
Contributor

We hit this in our fork as well and fixed here: qntfy#4

@JoshuaC215
Copy link
Contributor

Here's a test case to demonstrate the issue:

        {
                desc:    `handle non-object and skip`,
                json:    `{"a":"d","c":{"c":[1,2]}} }`,
                path:    []string{"a", "c"},
                isFound: false,
        },
--- FAIL: TestGet (0.00s)
        parser_test.go:1022: Get() test 'handle non-object and skip' isFound mismatch: expected false, obtained true

@AllenX2018
Copy link
Collaborator

This issue seems to be closed.

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

No branches or pull requests

3 participants