Added exception-safe code when loading JSON with loadJSON function.