开发者

asp.net json .net objects

I have this class.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace TestConnect
{
    public class UserInfo
    {
        public string id { get; set; }
        public string name { get; set; }
        public string picture { get; set; }
        public string bio { get; set; }
        public string quotes { get; set; }
        //public HometownInfo from { get; set; 
        public From hometown { get; set; }
        public string relationship { get; set; }
        public string gender { get; set; }
        public List<Education> data { get; set; }
     }

    public class Education
    {

        public From school { get; set; }
        public From year { get; set; }
        //public From [] concentration { get; set; }
        public string type { get; set; }

    }

}

public class HometownInfo
{
    public string id { get; set; }
    public string homename { get; set; }
}

Now trying to do

url = "https://graph.facebook.com/me?fields=education&access_token=" + oAuth.Token;
json = oAuth.WebRequest(oAuthFacebook.Method.GET, url, String.Empty);
Education edu = js.Deserialize<Education>(json);

foreach(Education_history edu_history in Education.data) gives an error

Object reference not se开发者_开发百科t to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request

Thanks User


Have you tried setting breakpoints at the various steps in your code and seeing where it might be?

somewhere else in your code you must be declaring url and json?

does js.Deserialize() create a new object or are you missing this Education edu = new Education();

Also if its in a web application make sure that your code is placed in the correct page events so that they happen in the correct order

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜