2016-02-19 PerlでJsonをencodeするときにsortされた状態で出力したい Perl json TL;DR use JSON::PP JSON::PP->new->utf8->canoical(1)->encode(...) すればkeyのalphabet順になる refs: http://stackoverflow.com/questions/3532067/perl-how-to-sort-a-json-structure-on-something-other-than-root-key-attributes はじめに クライアントに渡すjsonデータを生成するとkeyの順番がバラバラで出力されていた。 これだと差分が無いのにGithubのPull-Requestで差分がでるのでリリースチェックするときに邪魔だった。 Key順にする 結論として JSON::PP を使えば解決できた 冒頭で書いたように canonical を On にすればkey順にsortされる