Refactored the JsonSerializable fallback to be easier to understand