title: Remove trailing spaces from Web API JSON
body: <p>I am creating a Web API application that wraps up some legacy systems underneath which have databases that using nchar instead of nvarchar for all string columns.</p>
  
  <p>This obviously give me the issue that all strings that come from the database have a load of white space to pad them out to the field length at the end.</p>
  
  <p>As I am returning JSON, I would like to make sure that the JSON is minified as much as possible and trim the strings.  What I don't want to have to do is perform a <code>TrimEnd()</code> on all of my strings manually in the code.</p>
  
  <p>To achieve this, I was thinking that I could do this in the JSON serialiser being used by WebAPI to output the object.  I have tried looking around in </p>
  
  <pre><code>GlobalConfiguration.Configuration.Formatters.JsonFormatter
  </code></pre>
  
  <p>to see if I can find a way to do this but I am struggling to find a viable option.</p>
  
  <p>Has anyone tried to do this before and how have they managed to do it without a manual loop through the fields and without creating a significant performance overhead?</p>