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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:30:24+00:00 2026-05-18T01:30:24+00:00

I have a json object full of ips like var ips = {} I

  • 0

I have a json object full of ips like

var ips = {}

I then add ip objects to this object like so

ips[ipID] = {}

I then need to add dynamic/variable name value pairs to each ip so I am using code like this

var name; var value; var temp = {};
tmp[name] = value

My question is, how can I add these name value pairs/ tmp to my ipID objects so that my outcome turns out like

ipID = { name : value, anotherName : anotherValue }
  • 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-18T01:30:25+00:00Added an answer on May 18, 2026 at 1:30 am

    That’s not JSON. It’s just Javascript objects, and has nothing at all to do with JSON.

    You can use brackets to set the properties dynamically. Example:

    var obj = {};
    obj['name'] = value;
    obj['anotherName'] = anotherValue;
    

    This gives exactly the same as creating the object with an object literal like this:

    var obj = { name : value, anotherName : anotherValue };
    

    If you have already added the object to the ips collection, you use one pair of brackets to access the object in the collection, and another pair to access the propery in the object:

    ips[ipId] = {};
    ips[ipId]['name'] = value;
    ips[ipId]['anotherName'] = anotherValue;
    

    Notice similarity with the code above, but that you are just using ips[ipId] instead of obj.

    You can also get a reference to the object back from the collection, and use that to access the object while it remains in the collection:

    ips[ipId] = {};
    var obj = ips[ipId];
    obj['name'] = value;
    obj['anotherName'] = anotherValue;
    

    You can use string variables to specify the names of the properties:

    var name = 'name';
    obj[name] = value;
    name = 'anotherName';
    obj[name] = anotherValue;
    

    It’s value of the variable (the string) that identifies the property, so while you use obj[name] for both properties in the code above, it’s the string in the variable at the moment that you access it that determines what property will be accessed.

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

Sidebar

Related Questions

I have json object like this, the site is running codeigniter which is ultimately
I have a json object that i send as a template variable to my
I have a JSON object collection: var Gallery = [ { Order: 1, Page:
I have a json object with a function: var thread = { title: my
I have a json object that follows the following structure: $foo->bar['1']->#foobar The hash is
Ok so i have the json object returned back from my script and I
Edit to answer: I have tried the following $(document).ajaxSuccess (function(ev, xhr, s) { document.write('url:
I am new with liftweb and scala. I am developing json-rest api for rss
This is the only official documentation available for the Halo: Reach stats API. If
I use $.ajax() to get some HTML pages from my server. The retrun contains

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.