title: Reading WCF JSON Serialization
body: <p>I've recently tried to output JSON using the built-in WCF functionality rather than the JSON.net kit over at Newtonsoft.</p>
  
  <p>I'm getting the JSON to output okay, but I'm still left behind some strange default Serialization markup left by WCF.</p>
  
  <p>Here is what is outputted to the client doing a GET:</p>
  
  <pre><code>&lt;string xmlns="http://schemas.microsoft.com/2003/10/Serialization/"&gt;{"LobbyID":2,"LobbyID2":0}&lt;/string&gt;
  </code></pre>
  
  <p>I would like to be rid of the "xmlns="http://schemas.microsoft.com/2003/10/Serialization/" if possible, so it is just a straight JSON data type response.</p>
  
  <p>Here is the lobby class with the relevant DataContracts:</p>
  
  <pre><code>[DataContract(Name = "LobbyContract", Namespace = "xx")]
  public class Lobby
  {
      [DataMember(Name="LobbyID")]
      private int LobbyID;
  
      [DataMember(Name = "LobbyID2")]
      private int LobbyID2;
  </code></pre>
  
  <p>and then I have this call functionality:</p>
  
  <pre><code>    [OperationContract]
      [Description("PlaceHolder")]
      [WebGet(UriTemplate = "xxx/xx/{gameID}/{format}") ]
      public string FindGameProposals(string gameID, string format)
      {
  
          Lobby lobby = new Lobby();
          lobby.SetLobbyID(Convert.ToInt32(gameID));
  
          string returnValue = "";
          if (format == "xml")
          {
  
          }
  
          else if (format == "json")
          {
  
              DataContractJsonSerializer serializer = new DataContractJsonSerializer(lobby.GetType());
              MemoryStream memoryStream = new MemoryStream();
              serializer.WriteObject(memoryStream, lobby);
  
              // Return the results serialized as JSON
              string json = Encoding.Default.GetString(memoryStream.ToArray());
              returnValue = json;
  
  
  
          }
          return returnValue;
      }
  </code></pre>
  
  <p>Obviously thanks for any advice or general direction I should be looking at, but I've gone through most examples and tutorials but alas they were to no avail.
  It is a very simple test, whereby I perform the GET with a number, the service reads the number, assigns it to the class's ID variable, and then I read it, serialize it and send it back.</p>