Fix undefined subroutine encode_json when using -x json. Thanks to jason for the report.