add error handler for encode json
Merge branch 'fix-json-err-handling' into dev