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

  • Home
  • SEARCH
  • 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 7908557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:59:48+00:00 2026-06-03T11:59:48+00:00

(context)I have information from a bunch of elements that I’m collecting into a JSON

  • 0

(context)I have information from a bunch of elements that I’m collecting into a JSON object that then gets passed down to an MVC3 controller where it gets deserialized into an object.

There are ‘items’ and ‘item settings’. Currently, I have have both items and item settings all in flat JSON object. Ideally I would like to have the item settings nested under each item. My code currently looks like this:

 var editeditems=[];
...

        $("#SaveChanges").click(function() {

            //this works and retrieves all of the item IDs
            $(".portlet").each(function() {

                var itemname = $(this).data("itemname");
         editeditems.push(
                        {
                            "itemname": itemname
                        });

   itemname = $(this).data("itemname");

      $(".settingInput").each(function() {

          editeditems.push(
              {
              "settingkey":$(this).attr("name"),
              "settingvalue":$(this).attr("value")
              });


                });


 });

Under the $(“.settingInput”).each function is where the settings get added. I’ve tried syntax like ‘editedItems.settings.push..’ but it returns with a syntax error.

Any help would greatly be appreciated!

  • 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-06-03T11:59:55+00:00Added an answer on June 3, 2026 at 11:59 am
    var editeditems = [];
    ...
    
    $('#SaveChanges').click(function() {
        $('.portlet').each(function() {
            var settings = [];
            $('.settingInput').each(function() {
                settings.push({
                    settingkey: $(this).attr('name'),
                    settingvalue: $(this).attr('value')
                });
            });
    
            editeditems.push({
                itemname: $(this).data('itemname'),
                settings: settings
            });
        });
    
        ...
    });
    

    will generate sample output:

    var editeditems = 
    [
        {
            "itemname": "item1",
            "settings": [
                {
                    "settingkey": "key1",
                    "settingvalue": "value1"
                },
                {
                    "settingkey": "key2",
                    "settingvalue": "value2"
                }
            ]
        },
        {
            "itemname": "item2",
            "settings": [
                {
                    "settingkey": "key1",
                    "settingvalue": "value3"
                },
                {
                    "settingkey": "key2",
                    "settingvalue": "value4"
                }
            ]
        }
    ];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two cases to extract information from the IDataReader object Case - 1
I've got an issue that's been bothering me. I have to store information from
I have a question about getting information from a MySQL database. The context is
I'm loading a page in Django that summarizes information from a bunch of database
I have an application that receives information from a database, and is used to
I have a view that displays object information when the correct URL is provided
Context: I have a class that implements a Session, maintaining a TCP connection to
I have a LINQ TO SQL Context that I have created that calls a
I have a core data context with objects that have a date stored in
I am trying to find a way to log useful context from a bunch

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.