jmespath / jmespath/go-jmespath

[question] examples of usage?

Open
#22 4 comments 1 reaction 0 assignees View on GitHub
question
Dominant language
Go
Stars
621
Forks
101
PR merge metrics
No merged PRs in 30d

Description

Hi, I mostly wonder what kind of data jmespath.Search() expects?
Param data says `interface{}` so it's not really helpful... can I use string `{}` or `[]byte("{}")` or what it should be?
From testcases I see that `map[string]interface{}` is used so it looks like output of json.Unmarshal... but is this the only data type that can be passed? Or maybe json string is allowed too?

Same questions apply to return value... what kind of data types I can expect? `interface{}` type suggest I can expect various data types, or maybe even self defined ones... but there is no info about it... so no idea what should I try to assert.

I was trying to do something simple like:

```
v, err := jmespath.Search("a.b", `{"a":{"b":"test"}}`)
log.Println(v)
```

but this doesn't seem to work

Also, considering jmespath.Search() returns `interface{}` then beside type assertion is there any nicer way to convert this some usable data type? Like `string` or `[]byte` or self defined `struct` (e.g. like with json.Unmarshal)?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.