JsonObjectSerializer.serialize - use own catch block for IOException.

Comment From: snicoll

Thanks but we don't need both a PR and an issue as the former supersedes the latter.