check if payload exists before adding it to json message
fix bug where json is used after refcount goes to zero