Fix json output when printing legend entries

Branch 1.4 is missing this patch in order to produce valid json output.
This is related to issue #380 reported by apfeiffe.