Break out deserialization to shared function.