Moved JSON parse out of switch statement