Skip to content

Parsed yaml returns sorted & comment free file #66

@rmartinoscar

Description

@rmartinoscar

When using https://pastes.dev/11FXTHnM2m yaml file lines are getting alphabetically sorted and any comments or blank line gets removed
Before
After
I think this is because we handle Yaml by converting it to Json then converting back to Yaml.

wings/parser/parser.go

Lines 433 to 452 in 9f1dbd4

// Unmarshal the yaml data into a JSON interface such that we can work with
// any arbitrary data structure. If we don't do this, I can't use gabs which
// makes working with unknown JSON significantly easier.
jsonBytes, err := json.Marshal(dyno.ConvertMapI2MapS(i))
if err != nil {
return err
}
// Now that the data is converted, treat it just like JSON and pass it to the
// iterator function to update values as necessary.
data, err := f.IterateOverJson(jsonBytes)
if err != nil {
return err
}
// Remarshal the JSON into YAML format before saving it back to the disk.
marshaled, err := yaml.Marshal(data.Data())
if err != nil {
return err
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions