Question

I am tired about parsing that json response :

I prepared class something for model:

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

Now time to deserialize response :

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

and this makes a app crash...

Anyone have idea what i do wrong?

Was it helpful?

Solution

You don't define permission for class, please chnge class Announcements to public class Announcements. Now it should work properly, test this tip please.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top