add try catch around json parse to avoid syntax error end of input when json malformed.