Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[YAML] Question about array dumping #16266

Closed
@nerdstein

Description

@nerdstein

I have a YML file that I parse, which has the following syntax for an empty array:

some_field: [ ]

Upon dumping the same YML file, and not adjusting some_field, the value is dumped as:

some_field: { }

My understanding is that the { } syntax is intended for objects, not arrays. As such, I isolated the code found in the dumpArray function which was introducing this behavior:

https://github.com/symfony/yaml/blob/2.8/Inline.php#L191

return sprintf('{ %s }', implode(', ', $output));

.... adjusted to ....

return sprintf('[ %s ]', implode(', ', $output));

... fixes this issue.

Is there a reason why this is using the object-based syntax and not the array syntax?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions