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

json.Number format is not supported #27

Open
shashankmehra opened this issue Mar 27, 2017 · 2 comments · May be fixed by #82
Open

json.Number format is not supported #27

shashankmehra opened this issue Mar 27, 2017 · 2 comments · May be fixed by #82

Comments

@shashankmehra
Copy link
Contributor

If json is Unmarshaled using json.Number format like:

my_map := make(map[string]interface{})
d := json.NewDecoder(strings.NewReader(json_raw))
d.UseNumber()
d.Decode(&my_map)

And then used to search:

var expr1 = jmespath.MustCompile("people[?age > `20`].[name, age]")
result, err := expr1.Search(my_map)

err is nil but the result is [] even though some objects must be returned. Removing the d.UseNumber() makes the Search work properly.

This is probably because this type assertion fails to recognize the value in the map as a Number (float): https://github.com/jmespath/go-jmespath/blob/master/interpreter.go#L48

json.Number is essentially a string. So either reflect/conversion library can be used here or type assertion should handle json.Number.

@suntong
Copy link

suntong commented Jun 2, 2018

Looks to me a reasonable request.

@liov
Copy link

liov commented Mar 6, 2019

same as above

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

Successfully merging a pull request may close this issue.

3 participants