JSON::XS 4.0 では incompatible な変更がいくつかあるので注意

最近 JOSN::XS 4.0 が出たわけですが、Changes が以下のようになっております。

Changes for version 4.0 - 2018-11-16
・4.0 pre-release, do not use other than for testing.
・SECURITY IMPLICATION: this release enables allow_nonref by default for compatibnility with RFC 7159 and newer. See "old" vs. "new" JSON under SECURITY CONSIDERATIONS.
・reworked the "old" vs. "new" JSON section.
・add ->boolean_values to provide the values to which booleans decode (requested by Aristotle Pagaltzis).
・decode would wrongly accept ASCII NUL characters instead of reporting them as trailing garbage.
・work around what smells like a perl bug w.r.t. exceptions thrown in callbacks.
・incremental parser now more or less respects allow_nonref.
json_xs json-pretty now enables canonical mode.
・add documentation section about I-JSON.
・minor documentation fixes/updates.

まだ pre-release だから test 目的以外では使うなよって書いてありますね。developer release にしなかったのはなんでやろ(教えてエロい人!)
この変更では、RFC 7159 に沿うように、encode 時に `allow_nonref` がデフォルトで有効になりました。

いままでは以下のようなパターンではエラーになっていましたが、動作するようになっています。

encode_json("hoge") # ok
JSON->new->utf8->encode("fuga") # ok

特筆すべきは、`JSON->new` の時点で有効になっているということでしょう。
オフにするには明示的に

JSON->new->allow_nonref(0)

とする必要があります。

`decode_json` では今まで通りにエラーになるので、そこまで問題にならないと思いますが、JSON::XS 4.0 以降では気をつける必要がありそうです。