fixed null pointer error and fixed json error messages.

Change-Id: Iaca2fa59ade4ce32201568618f03df2dbee6ac12