Refactoring of JSON serialization.