title: What is the best way to handle versioning using JSON protocol?
body: <p>I am normally writing all parts of the code in C# and when writing protocols that are serialized I use FastSerializer that serializes/deserializes the classes fast and efficient. It is also very easy to use, and fairly straight-forward to do "versioning", ie to handle different versions of the serialization. The thing I normally use, looks like this:</p>
  
  <pre><code>public override void DeserializeOwnedData(SerializationReader reader, object context)
  {
      base.DeserializeOwnedData(reader, context);
      byte serializeVersion = reader.ReadByte(); // used to keep what version we are using
  
      this.CustomerNumber = reader.ReadString();
      this.HomeAddress = reader.ReadString();
      this.ZipCode = reader.ReadString();
      this.HomeCity = reader.ReadString();
      if (serializeVersion &gt; 0)
          this.HomeAddressObj = reader.ReadUInt32();
      if (serializeVersion &gt; 1)
          this.County = reader.ReadString();
      if (serializeVersion &gt; 2)
          this.Muni = reader.ReadString();
      if (serializeVersion &gt; 3)
          this._AvailableCustomers = reader.ReadList&lt;uint&gt;();
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>public override void SerializeOwnedData(SerializationWriter writer, object context)
  {            
      base.SerializeOwnedData(writer, context);
      byte serializeVersion = 4; 
      writer.Write(serializeVersion);
  
  
      writer.Write(CustomerNumber);
      writer.Write(PopulationRegistryNumber);            
      writer.Write(HomeAddress);
      writer.Write(ZipCode);
      writer.Write(HomeCity);
      if (CustomerCards == null)
          CustomerCards = new List&lt;uint&gt;();            
      writer.Write(CustomerCards);
      writer.Write(HomeAddressObj);
  
      writer.Write(County);
  
      // v 2
      writer.Write(Muni);
  
      // v 4
      if (_AvailableCustomers == null)
          _AvailableCustomers = new List&lt;uint&gt;();
      writer.Write(_AvailableCustomers);
  }
  </code></pre>
  
  <p>So its easy to add new things, or change the serialization completely if one chooses to. </p>
  
  <p>However, I now want to use JSON for reasons not relevant right here =) I am currently using <strong>DataContractJsonSerializer</strong> and I am now looking for a way to have the same flexibility I have using the FastSerializer above.</p>
  
  <p>So the question is; what is the best way to create a JSON protocol/serialization and to be able to detail the serialization as above, so that I do not break the serialization just because another machine hasn't yet updated their version?</p>