Switch to json parsing.

Add additional error logging.