Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6901779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:42:58+00:00 2026-05-27T07:42:58+00:00

I’m looking to bind a JSON object to a List nested in an object.

  • 0

I’m looking to bind a JSON object to a List nested in an object.

Background

I have a Category class that contains a list of ConfigurationFunds:

public class Category
{
    public int Id { get; set; }
    public string CountryId { get; set; }
    public string Name { get; set; }

    public List<ConfigurationFund> Funds { get; set; }

    public Category()
    {
        Funds = new List<ConfigurationFund>();
    }
}

public class ConfigurationFund 
{
    public int Id { get; set; }
    public string CountryId { get; set; }
    public string Name { get; set; }

    public ConfigurationFund()
    {

    }
}

The user can select a number of Funds per Category, and then I want to POST a JSON string back to my Controller and have the ModelBinder bind the JSON to the object model.

This is my Action method:

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Edit(Category category) 
{
    // Categoy.Id & Categoy.CountryID is populated, but not Funds is null
    return Json(true); // 
}

So far, I have this jQuery:

$('#Save').click(function (e) {
    e.preventDefault();

    var data = {};

    data["category.Id"] = $('#CategorySelector').find(":selected").val();
    data["category.countryId"] = $('#CategorySelector').find(":selected").attr("countryId");

    var funds = {};
    $('#ConfiguredFunds option').each(function (i) {
        funds["funds[" + i + "].Id"] = $(this).val();
        funds["funds[" + i + "].countryId"] = $(this).attr("countryId");
    });

    data["category.funds"] = funds;

    $.post($(this).attr("action"), data, function (result) {
        // do stuff with response
    }, "json");
});

But this isn’t working. The properties of Category are populated, but the List<ConfigurationFund>() isn’t being populated.

Question

How do I need to modify this to get it to work?

Supplementary Info

Just to note, I’ve also tried to post the Category & ConfiguredFunds separately, and it works, with something similar to the following:

$('#Save').click(function (e) {
    e.preventDefault();

    var data = {};

    data["category.Id"] = $('#CategorySelector').find(":selected").val();
    data["category.countryId"] = $('#CategorySelector').find(":selected").attr("countryId");

    $('#ConfiguredFunds option').each(function (i) {
        data["configuredFunds[" + i + "].Id"] = $(this).val();
        data["configuredFunds[" + i + "].countryId"] = $(this).attr("countryId");
    });

     $.post($(this).attr("action"), data, function (result) {
        // do stuff with response
    }, "json");
});

In the following Action method, the ConfiguredFunds are populated, and the Category is also populated. However, the Category’s List isn’t populated. I need the Category & its List to be populated.

public ActionResult Edit(List<ConfigurationFund> configuredFunds, Category category)
{
    return Json(true);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:42:59+00:00Added an answer on May 27, 2026 at 7:42 am

    I’ve figured it out. I just needed to change

    data["category.Id"] = $('#CategorySelector').find(":selected").val();
    data["category.countryId"] = $('#CategorySelector').find(":selected").attr("countryId");
    
    var funds = {};
    $('#ConfiguredFunds option').each(function (i) {
        funds["funds[" + i + "].Id"] = $(this).val();
        funds["funds[" + i + "].countryId"] = $(this).attr("countryId");
    });
    
    data["category.funds"] = funds;
    
    $.post($(this).attr("action"), data, function (result) {
        // do stuff with response
    }, "json");
    

    to:

    data["category.Id"] = $('#CategorySelector').find(":selected").val();
    data["category.countryId"] = $('#CategorySelector').find(":selected").attr("countryId");
    
    $('#ConfiguredFunds option').each(function (i) {
        data["category.funds[" + i + "].Id"] = $(this).val();
        data["category.funds[" + i + "].countryId"] = $(this).attr("countryId");
    });
    
    $.post($(this).attr("action"), data, function (result) {
        // do stuff with response
    }, "json");
    

    Basically, I just specified that the funds belong to a Category with data["category.funds"]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.