log errors and parse JSON