Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Serialize a map to YAML with a specific order

I use the yaml library to serialize a value of type Map String t (or some type t). The order in the resulting output is rather random, which is suboptimal, as the file should be human readable.

Is there a way to control the serialization order of a map? Or, probably closer to the core of the problem, an aeson Object? If not, what are suitable workarounds?

like image 678
Joachim Breitner Avatar asked Feb 02 '14 10:02

Joachim Breitner


1 Answers

With yaml, or aeson on which it is based, it is currently not easily possible, says the yaml author, but he has started some experimental support for it in the form of the Data.Yaml.Builder module.

like image 195
Joachim Breitner Avatar answered Sep 27 '22 21:09

Joachim Breitner