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 8027475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:49:26+00:00 2026-06-04T23:49:26+00:00

I am trying to dynamically add and remove JSON elements from json object. But

  • 0

I am trying to dynamically add and remove JSON elements from json object. But its not updating in JSON.stringify output.

{
    "selected_stores": [
        {
            "row_0": "3366::1148",
            "row_1": "3366"
        }
    ]
}

I am trying to add more elements in it . like row_2 an so but it doesn’t work. after adding new element console.log(obj); logs new element. but output is not updated.

Check my Fiddle

Thanks in advance.

  • 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-04T23:49:27+00:00Added an answer on June 4, 2026 at 11:49 pm

    The problem was that the selected_stores object is an array with a single element: an object that contains multiple properties. The code however, assumed that the array was an array of multiple objects (one for each row).

    You’ll probably want to update your JSON structure to this:

    {
        "selected_stores": [
            {
                "row_0": "3366::1148"
            },{
                "row_1": "3366"
            }
        ]
    }
    

    If you meant to write the JSON the way you did, all that needed to be done in the code was to make a reference to the selected_stores first array element: the object that contained the row properties:

    selected_stores_jsonObj.selected_stores[0]['row_' + row_num] = outcheckedStr;

    http://jsfiddle.net/4TzRC/28/

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

Sidebar

Related Questions

I am trying to add the remove buttons dynamically from a jQuery UI Dialog,
Here i am trying to dynamically add and remove the tab from uitabbarcontroller .
I'm trying to dynamically add buttons to the userform, but the userform just comes
we are trying to add ColumnDefinition to a Grid in WPF dynamically from code
I can generate the controls but can't remove them. I'm trying to add a
Hello I'm trying to dynamically generate some inputs for my form, but it's not
New to javascript and jQuery, but I'm trying to dynamically add buttons and then
I'm trying to dynamically add elements to a Cakephp form: <?php echo $javascript->link('jquery',false); ?>
I'm trying to dynamically add elements to a vector that is contained within a
I'm trying to dynamically create and remove items from a list, it works just

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.