Add json-serializer error handling

This PR targets #635.

It only contains logging calls by now, as I'm not sure what to do when
the serialization fails. It should not fail, of course. But if that happens
we could almost do an shutdown, as the serialization should only fail if
no memory is left, and ... yeah... you get it, I guess.

What to do in case of error? Clean up, of course, but what else? Is
logging enough?