improved Mojo::JSON to handle encoding errors more gracefully