0

I am needing to add one object to another and not sure how.I need to add phonegroup to the forward object that is inside of the frontdesk object. Does anyone know how this can be done? mind you there is potential for a different object to be attached to forward as well so this has to be something that is scale-able

var frontdesk = {
    "frontdesk": {
        "user": "",
        "waittime": "",
        "forward": {}
    }
}

var phonegroup = {
    "phonegroup": {
        "name": "",
        "users": [
            "",
            "",
            ""
        ],
        "noanswer": {
            "forwardafterrings": "",
            "forwardafterseconds": "",
            "forwardto": ""
        }
    }
}
1
  • 1
    What do you want the result to look like? Commented May 9, 2013 at 15:38

2 Answers 2

3

Try this using extend():

var object = $.extend({}, frontdesk, phonegroup);
console.log(object);
Sign up to request clarification or add additional context in comments.

Comments

1

forward is empty... do you really need to join the objects, or can you simply replace forward with phonegroup?

frontdesk.frontdesk.forward = phonegroup;

will do it, if you can simply replace the object.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.