Refactored fromJSON methods to remove duplication