title: TypeScript: how to serialize and deserialize object with different names via class-transformer
body: <p>I have <code>User</code> object with <code>firstName</code> property. I want to deserialize it from <code>first_name</code> but serialize it as <code>firstName</code>.</p>
  <p>My TypeScript code:</p>
  <pre><code>import { Expose, Exclude, classToPlain, plainToClass } from &quot;class-transformer&quot;;
  import &quot;reflect-metadata&quot;;
  
  @Exclude()
  class User {
    @Expose({ name: &quot;first_name&quot;, toClassOnly: true })
    firstName: string;
  
    constructor(s: Partial&lt;User&gt; = {}) {
      Object.assign(this, s);
    }
  }
  
  const user = plainToClass(User, { first_name: &quot;Mari&quot; });
  console.log(user); // { firstName: &quot;Mari&quot; }
  
  const plainSettings = classToPlain(user);
  console.log(plainSettings); // { first_name: &quot;Mari&quot; }
  </code></pre>
  <p><a href="https://stackblitz.com/edit/typescript-zyq1up" rel="nofollow noreferrer">LIVE DEMO</a></p>
  <p>I want <code>classToPlain</code> to serialize property as <code>firstName</code>. Using double <code>@Expose</code> ignores the second one:</p>
  <pre><code>@Expose({ name: &quot;first_name&quot;, toClassOnly: true })
  @Expose({ name: &quot;firstName&quot;, toClassOnly: false})
  firstName: string;
  // the same behaviour
  </code></pre>
  <p>Is there way to serialize/deserialize object with different property names?</p>