title: JSON.Net VB deserialize not working
body: <p>I'm new to VB and trying to write a webservice that exports and imports JSON.</p>
  
  <p>I'm using JSON.NET 3.5 and can serialize fine:</p>
  
  <p>My Token class is:</p>
  
  <pre><code>&lt;DataContract()&gt; _
    Public Class Token
      &lt;DataMember()&gt; _
      Public TokenID As String
  
      &lt;DataMember()&gt; _
      Public Issued As Date
  
      &lt;DataMember()&gt; _
      Public Expires As Date
  
      &lt;DataMember()&gt; _
      Public UserName As String
  
      &lt;DataMember()&gt; _
      Public CompanyID As String
  
      &lt;DataMember()&gt; _
      Public ApplicationID As Double
  
      &lt;DataMember()&gt; _
      Public UserID As Double
  
      &lt;DataMember()&gt; _
      Public DeviceID As Double
  
      &lt;DataMember()&gt; _
      Public DeviceSerialNumber As String
  
      &lt;DataMember()&gt; _
      Public IsValid As Boolean
  
      &lt;DataMember()&gt; _
      Public DebugText As String
  </code></pre>
  
  <p>(I started with MS's serialization but thought i'd try JSON.NET)</p>
  
  <p>I serialize with:</p>
  
  <p>Dim ThisToken as New Token
  ThisToken.DebugText = "blah"
  and so on</p>
  
  <pre><code>    JSONString = Newtonsoft.Json.JsonConvert.SerializeObject(ThisToken)
  </code></pre>
  
  <p>And I get this output from the webservice:</p>
  
  <p>{"TokenID":"9eaae348-5cbd-46ac-8ba9-83720ac07740","Issued":"/Date(1300422761886+0800)/","Expires":"/Date(1300465961886+0800)/","UserName":"1234","CompanyID":"6","ApplicationID":1.0,"UserID":29.0,"DeviceID":1.0,"DeviceSerialNumber":"9149520800758","IsValid":true,"DebugText":""}</p>
  
  <p>So far so good I think.</p>
  
  <p>To test that deserialization is working, I thought i'd try and deserialise what I just serialised. So I create a webservice that accepts a string and I paste the above into it.</p>
  
  <p>code to deseralise is:</p>
  
  <pre><code>    Dim ThisToken As New Token
  
      ThisToken = Newtonsoft.Json.JsonConvert.DeserializeObject(JSonString)
  </code></pre>
  
  <p>When I run the code using VS2005 internal debug/IE testing, I get an http500 internal server error.</p>
  
  <p>I also get the same problem if I try to deserialize immediately after serializing.</p>
  
  <p>I think part of the problem is that the code I was following was c#; from the json.net page:</p>
  
  <pre><code>Product deserializedProduct = JsonConvert.DeserializeObject&lt;Product&gt;(json);
  </code></pre>
  
  <p>I can see that in c# there is a <code>&lt;Product&gt;</code> part which is not readily apparant in vb ?</p>
  
  <p>I have no doubt that the newtonsoft json.net product works fine; I'm sure that i'm not doing something right.</p>
  
  <p>Help ?</p>
  
  <p>Andrew</p>