I am running into an issue where co-managers are breaking my JSON deserialization process. It seems that when you have a co-manager it adds a new object level instead of following Managers -> Manager -> Properties

With the Co-Manager it goes Managers -> Manager -> [0] -> Properties

Anyone run into this and if so what was the fix?

        // GET: /YahooTest/
        public ActionResult Index()
            OAuthSession session = (OAuthSession)Session["oAuthSession"];

            IToken requestToken = (IToken)Session["oAuthToken"];

            string oAuthVerifier = Request.QueryString["oauth_verifier"];

            const string requestURL = "<https://query.yahooapis.com/v1/yql?q=select%20>*%20from%20fantasysports.teams%20where%20league_key%20%3D%20'328.l.3973'&format=json";

            var content = STEALFantasyBaseball.Services.YQL.YQLResult(session, requestToken, oAuthVerifier, requestURL);

                var yahooresult = JObject.Parse(content);

                var result = yahooresult["query"]["results"]["team"];

                var model = JsonConvert.DeserializeObject<ICollection<Team>>(result.ToString());

                return View(model);


2 Replies
  • Hi Matt -

    This is consistent with how the JSON is returned. It is the same when you have multiple leagues or multiple players. For example, if you are querying teams within a league, I would expect the format to come back: Fantasy Content -> Teams -> Team [0] Fantasy Content -> Teams -> Team [1] etc

    You would then have to cycle through the Team array for each team to get the info.

    This would be consistent for a team that have multiple managers as well.

    I can help if you're using PHP, otherwise I don't know enough to help you processing the array.

  • I am using .NET with in the MVC framework. It actually appears to be the way that the JSON.NET library is assigning objects vs the model that I am using to provide them to the view, so I am going to have to change that I believe. I do not run into the issue with multiple leagues though which is strange. It is only happening with the co-managers.

    I will keep digging!


Recent Posts

in Fantasy Sports API