JSON serialization refactor