title: Storing a list of string in Claim (System.Security.Claims)
body: <p>I'm developing a web app with Asp.Net 5 MVC, Owin and Oauth2 bearer token as auth type.</p>
  
  <p>I need to store a list of string <code>"CODEFOO,CODBAR,CODEX,.."</code> inside a <a href="http://msdn.microsoft.com/en-us/library/system.security.claims.claim%28v=vs.110%29.aspx">System.Security.Claims.Claim</a> with a custom claim Type. </p>
  
  <p>When the user requests a token, this list of "user codes" is get from the back-end and set inside the identity using a specific custom claim type.<br>
  When the user sends the token back, navigating a specific MVC Action, the application has to check if the list of user codes inside the claim, contains a specific code.</p>
  
  <pre><code>List&lt;string&gt; userCodes = rep.GetUserCodeFromBackEnd();
  string userCodesClaimType = "http://foo.it/claim/usercodesclaimtype";
  </code></pre>
  
  <p>Right now I'm serializing the list of string in JSON.</p>
  
  <pre><code>var claim = new Claim(userCodesCaimType, JsonConvert.SerializeObject(userCodes));
  </code></pre>
  
  <p>and get it back de-serializing it with something like this:</p>
  
  <pre><code>var userCodesClaim = identity.Claims.FirstOrDefault&lt;Claim&gt;(c=&gt;c.Type == userCodesClaimType) ;
  var userCodesClaimValue = JsonConvert.DeserializeObject&lt;List&lt;string&gt;&gt;(userCodesClaim.Value);
  </code></pre>
  
  <p>Now the question:
  is there a better way to store a list of values inside a claim?<br>
  Claim has a <a href="http://msdn.microsoft.com/en-us/library/system.security.claims.claim.valuetype%28v=vs.110%29.aspx">ValueType</a> property which documentation says:</p>
  
  <blockquote>
    <p>The ValueType property contains a string that identifies the type
    information of the value. This property can be used to understand the
    format of the value and to provide information about how to serialize
    and deserialize the value. If your solution requires complex value
    types, it is recommended that you use standard XML schema types in the
    ValueType property to indicate how the Value property is meant to be
    serialized and deserialized from a string.</p>
  </blockquote>
  
  <p>Unluckily I have not found any example that documents the use of that property.<br>
  Is the Json serialization ok or should I use the ValueType approach?</p>