Eu tenho esse JSON
[{
"new_as_cod": "0010955",
"as_nome": "NAME",
"as_cpf": "1212121212",
"as_email": "IM@UOL.COM.BR",
"as_cep": "88.025-200",
"igr_nome": "1\u00aa IGREJA BATISTA - FLORIANOPOLIS",
"id": "2781",
"valor": "50.00",
"pg_tipo_id": "CC",
"status": "Ativo",
"idstatus": "1"
}]
a classe foi gerada a partir daqui
public class RootObject
{
public string new_as_cod { get; set; }
public string as_nome { get; set; }
public string as_cpf { get; set; }
public string as_email { get; set; }
public string as_cep { get; set; }
public string igr_nome { get; set; }
public string id { get; set; }
public string valor { get; set; }
public string pg_tipo_id { get; set; }
public string status { get; set; }
public string idstatus { get; set; }
}
Tenho tentado usar essa expressão.
RootObject data = JsonConvert.DeserializeObject<RootObject>(stringdate);
as_nome.Text = data.as_nome.ToString();
as_cpf.Text = data.as_cpf.ToString();
Mas está dando este erro.
An exception of type 'Newtonsoft.Json.JsonSerializationException' occurred in Newtonsoft.Json.DLL but was not handled in user code Additional information: Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'HelloWorldWP.MainPage+RootObject' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.