cloudfoundry / cloudfoundry/jsonry
parsing error for arrays of objects
Open
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 6
- Forks
- 1
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 5
Description
package main
import (
"fmt"
"code.cloudfoundry.org/jsonry"
)
func main() {
data := `{"nfs":[{"volume_mounts":[{"container_dir":"foo"}]}]}`
var receiver struct {
Paths []string `jsonry:"nfs.volume_mounts.container_dir"`
}
if err := jsonry.Unmarshal([]byte(data), &receiver); err != nil {
panic(err)
}
fmt.Printf("%+v", receiver.Paths)
}
You'd expect this to extract the string foo, but it panics with:
panic: cannot unmarshal "[foo]" type "[]interface {}" into index 0 (type "string") path Paths[0]
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the example with jsonry.Unmarshal and trace how the nfs.volume_mounts.container_dir path is handled for arrays of objects. Done means the example completes without panicking and receiver.Paths contains the extracted string "foo".
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100