Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[YAML] Question about array dumping #16266

Copy link
Copy link
Closed
@nerdstein

Description

@nerdstein
Issue body actions

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.