How do I export data into yaml with mapping? I am exporting module's libraries from PHP in modulename.libraries.yml. I am using the YAML parser.

\Drupal::service('serialization.yaml')-&gt;decode($data)


The issue I have encountered is that I cannot indicate JavaScript or CSS files to be minified because instead of filename: { minified: true } I will end up with the following.

filename:
  minified: true


Basing on a brief IRC chat, I get this is not possible. Is that correct? If it is so, is this a bug? Differently, can anybody tell me how can I achieve this?
Those two are semantically the same thing. The only difference is that the {} format is more compact.
See the output in these two links.

Regardless, the second argument to the dump method lets you configure the verbosity of arrays. See Writing YAML Files.