How to properly override the ReadJson method for a object[]?
<p>I'm trying to create a json converter for an object[] to define the types I want (int32 instead of int64 for example).</p>
<p>This is what i got until now:</p>
<p>The object:</p>
<pre><code>[JsonObject]
public class tipo
{
    public string teste { get; set; }

    [JsonConverter(typeof(TestConverter))]
    public object[] metodos { get; set; }
}
</code></pre>
<p>the main:</p>
<pre><code>    string call = JsonConvert.SerializeObject(new tipo { teste=&quot;nota&quot;,
    metodos = new object[] { 10, (decimal)10.5, &quot;Teste123&quot; } });

    tipo t = JsonConvert.DeserializeObject&lt;tipo&gt;(call);
</code></pre>
<p>The JsonConverter:</p>
<pre><code>namespace Newtonsoft.Json
{
public class TestConverter : JsonConverter
{
    #region Overrides of JsonConverter
    
    public override bool CanWrite { get { return false; } }
    
    public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
    {
        throw new NotImplementedException();
    }

    public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
    {
        List&lt;object&gt; resultado = new List&lt;object&gt;();

        string propertyName = reader.Value as string;
        while (reader.Read())
        {
            object value = null;

            switch (reader.TokenType)
            {
                case JsonToken.Integer:
                    value = Convert.ToInt32(reader.Value);
                    resultado.Add(value);
                    break;
                case JsonToken.Float:
                    value = Convert.ToDecimal(reader.Value);
                    resultado.Add(value);
                    break;
                case JsonToken.String:
                    value = Convert.ToString(reader.Value);
                    resultado.Add(value);
                    break;
                case JsonToken.Boolean:
                    value = Convert.ToBoolean(reader.Value);
                    resultado.Add(value);
                    break;
                case JsonToken.Null:
                    value = null;
                    resultado.Add(value);
                    break;
                case JsonToken.Date:
                    value = Convert.ToDateTime(reader.Value);
                    resultado.Add(value);
                    break;
                case JsonToken.Bytes:
                    value = Convert.ToByte(reader.Value);
                    resultado.Add(value);
                    break;
                default:
                    Console.WriteLine(&quot;Default case&quot;);
                    Console.WriteLine(reader.TokenType.ToString());
                    break;
            }
        }

        return resultado.ToArray();
    }
    
    public override bool CanConvert(Type objectType)
    {
        return objectType == typeof(object[]);
    }

    #endregion
    }
}
</code></pre>
<p>I checked the output and everything is ok, however it returns me the following error in deserialization:</p>
<blockquote>
<p>An unhandled exception of type 'Newtonsoft.Json.JsonSerializationException' occurred in Newtonsoft.Json.dll</p>
<p>Additional information: Unexpected end when deserializing object. Path '', line 1, position 47.</p>
</blockquote>
<p>Any idea how to solve this?</p>
<p>Thanks!!!</p>