Domanda

Sono stanco di analizzare la risposta json:

Ho preparato qualcosa in classe per il modello:

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; }
    }
}

Ora è il momento di deserializzare la risposta:

            var tempUsersArray = JsonConvert.DeserializeObject<Announcements.RootObject>(response.Content);

e questo fa crashare l'app...

Qualcuno ha idea di cosa sbaglio?

È stato utile?

Soluzione

Non definisci l'autorizzazione per la classe, per favore cambia class Announcements A public class Announcements.Ora dovrebbe funzionare correttamente, prova questo suggerimento per favore.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top