title: Deserializing JToken content to an Object
body: <p>I want to deserialize JToken content to an object (<code>User</code>). How am I able to do this?</p>
  <p><strong>Here is my json string:</strong></p>
  <pre><code>string json = @&quot;[{&quot;&quot;UserId&quot;&quot;:0,&quot;&quot;Username&quot;&quot;:&quot;&quot;jj.stranger&quot;&quot;,&quot;&quot;FirstName&quot;&quot;:&quot;&quot;JJ&quot;&quot;,&quot;&quot;LastName&quot;&quot;:&quot;&quot;stranger&quot;&quot;}]&quot;;
  </code></pre>
  <p>This being sent to an api parameter as <code>JToken</code>.</p>
  <p><strong>User class:</strong></p>
  <pre class="lang-cs prettyprint-override"><code>public class user
  {
      public int UserId {get; set;}
      public string Username {get; set;}
      public string FirstName {get; set;}
      public string LastName {get; set;}
  }
  </code></pre>
  <p><strong>Web Api Method:</strong></p>
  <pre class="lang-cs prettyprint-override"><code>public IHttpActionResult Post([FromBody]JToken users)
  {
        UserModel.SaveUser(users);
        //...
  }
  </code></pre>
  <p><strong>API Invocation in Salesforce:</strong></p>
  <pre><code>string json = '[{&quot;UserId&quot;:0,&quot;Username&quot;:&quot;jj.stranger&quot;,&quot;FirstName&quot;:&quot;JJ&quot;,&quot;LastName&quot;:&quot;stranger&quot;}]';
  HttpRequest req = new HttpRequest();
  HttpResponse res = new HttpResponse();
  Http http = new Http();
              
  req.setEndpoint('test.com/api/UserManagement');
  req.setMethod('POST');
  req.setBody(json);
  req.setHeader('Content-Type', 'application/json');
              
  try {
      res = http.send(req);
  } catch(System.CalloutException e) {
      System.debug('Callout error:' + e);
  }
              
  System.debug(res.getBody());
  </code></pre>