title: Json Serialization for Windows Phone
body: <p>I was trying to implement parsing a JSON response as shown <a href="https://stackoverflow.com/questions/1212344/parse-json-in-c/1218902#1218902">here</a> for my Windows Phone 7 project in C#. But I am stuck with a compilation error as "The type or namespace name 'Serializable' could not be found (are you missing a using directive or an assembly reference?)"</p>
  
  <p>I have the imports using System.Runtime.Serialization;
  using System.Runtime.Serialization.Json; I am not sure what are import I am missing. I tried to include using System.ServiceModel.Web; But the Web part is not recognized. </p>
  
  <p>I thought my project is not pointing to the right framework from <a href="https://stackoverflow.com/questions/4764978/the-type-or-namespace-name-could-not-be-found">here</a>. But in the Assembly information, there is no option for me to change the target framework.</p>
  
  <p><a href="https://stackoverflow.com/questions/3999117/parsing-json-on-windows-phone-7">This</a> looks like a similar problem to mine, but I couldn't find the JSON.NET in .net dlls which is filtered for Windows Phone.</p>
  
  <p>Can someone help me to get this JSON thing working for Windows Phone 7.</p>
  
  <p>Thank in Advance.</p>
  
  <p><strong>EDIT - 7/3/11</strong></p>
  
  <p>My Jason response is 
  { "serviceresponse" : { "servicename" : "RequestRegisterUser", .....</p>
  
  <p>And my Response objects are:</p>
  
  <pre><code>[DataContract]
         public class serviceresponse
         {
               [DataMember]
             public String servicename { get; set; }
             .
             .
             .
  </code></pre>
  
  <p>And my Deserialize method:</p>
  
  <pre><code> public static T Deserialise&lt;T&gt;(string json)
     {
         T obj = Activator.CreateInstance&lt;T&gt;();
         using (MemoryStream stream = new MemoryStream(Encoding.Unicode.GetBytes(json)))
         {
             DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(T));
             obj = (T)serializer.ReadObject(stream);
             return obj;
         }
     }
  </code></pre>
  
  <p>Now I am getting this error after Deserializing the response:
  servicename Could not evaluate expression   string</p>
  
  <p>( I could not import System.ServiceModel.Web though I have the dll in the reference. A compilation error on the .Web part (The type or namespace name 'Web' does not exist in the namespace 'System.ServiceModel') )</p>
  
  <p><strong>EDIT</strong> After more research, I found my response when viewed in the debugger is actually 
  {
      \"serviceresponse\": {
          \"servicename\": \"RequestRegisterUser\",.....
  I searched for this and found this could be a problem. How can I format it to correct JSON String??</p>