Como analisar essa resposta json?[fechado]
-
02-01-2020 - |
Pergunta
Estou cansado de analisar essa resposta json:
Preparei uma aula algo para o modelo:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Announcements
{
public class Private
{
public string created_at { get; set; }
public int id { get; set; }
public string text { get; set; }
public string title { get; set; }
public string updated_at { get; set; }
public int user_id { get; set; }
}
public class User
{
public string first_name { get; set; }
public int id { get; set; }
public string last_name { get; set; }
}
public class Public
{
public string created_at { get; set; }
public int id { get; set; }
public string text { get; set; }
public string title { get; set; }
public User user { get; set; }
}
public class RootObject
{
public List<Private> @private { get; set; }
public List<Public> @public { get; set; }
}
}
Agora é hora de desserializar a resposta:
var tempUsersArray = JsonConvert.DeserializeObject<Announcements.RootObject>(response.Content);
e isso faz com que o aplicativo trave ...
Alguém tem ideia do que eu faço de errado?
Solução
Você não define a permissão para a aula, altere class Announcements
para public class Announcements
.Agora deve funcionar corretamente, teste esta dica por favor.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow