catch json parsing errors

This allows to catch syntax errors in the json string. For example if the client just sends "undefined" in the body.