Added exception handling around all JSON code