Estou tentando gravar um retorno de um JSON em um arquivo txt. Porém quando tento usar o DeserializeObject
dá erro.
Tenho o Json abaixo (exemplo de 2 registros):
[
{
"TipoVeiculo": "Caminhão",
"CodigoMarca": 501,
"Marca": "AGRALE",
"CodigoModelo": 34,
"Modelo": "10000 / 10000 S 2p (diesel) (E5)",
"Ano": 2012,
"Combustivel": "Diesel",
"Valor": 96041.00
},
{
"TipoVeiculo": "Caminhão",
"CodigoMarca": 501,
"Marca": "AGRALE",
"CodigoModelo": 34,
"Modelo": "10000 / 10000 S 2p (diesel) (E5)",
"Ano": 2013,
"Combustivel": "Diesel",
"Valor": 100932.00
}
]
estou recuperando ele dessa forma:
IRestResponse response = client.Execute(request);
e tento efetuar:
TabelaFipe deserializedProduct = JsonConvert.DeserializeObject<TabelaFipe>(response.Content);
porém acontece o seguinte erro:
Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'TabelaFipe' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.
To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.
Path '', line 1, position 1.