Input string in not a valid number - JSON deserialization
<p>I have this array:</p>

<pre><code>{
    "AssemblyVersion":"0.1.333.5973",
    "Exception":
    {
        // [...]
    }
}
</code></pre>

<p>which is serialized from this class:</p>

<pre><code>public class ErrorData
{
    public string AssemblyVersion { get; private set; }
    public Exception Exception { get; private set; }

    public ErrorData(string assemblyVersion, Exception ex)
    {
        AssemblyVersion = assemblyVersion;
        Exception = ex;
    }

    public override string ToString()
    {
        return JsonConvert.SerializeObject(this);
    }
}
</code></pre>

<p>Serializing it back to an object produces the following exception:</p>

<pre><code>Newtonsoft.Json.JsonReaderException: Input string '0.1.335.5973' is not a valid number. Path 'AssemblyVersion', line 1, position 29.
    at Newtonsoft.Json.JsonTextReader.ParseNumber(ReadType readType)
    at Newtonsoft.Json.JsonTextReader.ReadStringValue(ReadType readType)
    at Newtonsoft.Json.JsonTextReader.ReadAsString()
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadForType(JsonReader reader, JsonContract contract, Boolean hasConverter)
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ResolvePropertyAndCreatorValues(JsonObjectContract contract, JsonProperty containerProperty, JsonReader reader, Type objectType)
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObjectUsingCreatorWithParameters(JsonReader reader, JsonObjectContract contract, JsonProperty containerProperty, ObjectConstructor`1 creator, String id)
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateNewObject(JsonReader reader, JsonObjectContract objectContract, JsonProperty containerMember, JsonProperty containerProperty, String id, Boolean&amp; createdFromNonDefaultCreator)
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
    at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
    at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
    at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
    at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
    at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value)
</code></pre>

<p>In a nutshell I'm serializing an ErrorData instance as a json string with the overridden <code>ToString()</code> method, passing the result as a command line argument to a child process which is deserializing it back to an ErrorData instance.</p>

<p>What am I missing? It seems like the AssemblyVersion string is seen as a number instead of a string.</p>

<p>Edit: </p>

<p>I'm deserializing it this way:</p>

<pre><code>ErrorData errorData = JsonConvert.DeserializeObject&lt;ErrorData&gt;(args[0]);
</code></pre>

<p>Serializing is already shown in the code above, I implemented it into ToString() method.</p>

<p>I can verify that it happens because I'm passing the array as a command line arg. This code here works:</p>

<pre><code>ErrorData errorData = Json.DeserializeObject&lt;ErrorData&gt;(new ErrorData("", new Exception()).ToString());
</code></pre>