Added support of onFailMessage and onErrorMessage for json format