-
Notifications
You must be signed in to change notification settings - Fork 1k
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
parsing data sequence into list #230
Comments
@vanloswang I'm getting this same error. How did you solve this? |
@alexforever86 Did you ever find a solution? |
After struggling with this for a couple hours, I figured it out 5 minutes after pinging this thread (apologies for that!) The comment in #101 (comment) was a huge help. In my case, I was trying to parse Ansible's ---
- src: franklinkim.php5-newrelic
- src: geerlingguy.composer
- src: geerlingguy.java
- src: geerlingguy.nginx
- src: geerlingguy.nodejs
- src: geerlingguy.php
- src: geerlingguy.php-versions
- src: geerlingguy.rabbitmq
- src: geerlingguy.solr
- src: newrelic.newrelic-infra
- name: mycustomrole
src: git@gitlab.example.com:foo/bar.git
scm: git
version: master
- src: https://github.com/nickhammond/ansible-logrotate
name: nickhammond.logrotate I had a struct like this, which was correct: type AnsibleSource struct {
Source string `yaml:"src"`
Name *string `yaml:"name,omitempty"`
Type *string `yaml:"scm,omitempty"`
Version *string `yaml:"version,omitempty"`
} But to properly unmarshall the top-level sequence (and solve the source, err := ioutil.ReadFile(ansibleRequirements.Path)
if err != nil {
return
}
var out []AnsibleSource
err = yaml.Unmarshal(source, &out)
if err != nil {
return
}
fmt.Println(requirements) Hope this helps someone else! |
The data is
The struct is
The parsing code is
then it failed with following infos:
2016/12/14 17:13:39 error: yaml: unmarshal errors: line 2: cannot unmarshal !!seq into main.NODE
The text was updated successfully, but these errors were encountered: