0

Hi all.

Suppose I have the following JSON Object:

"WorkPhone": {
  "Phone": {
    "FixedPhone": "98221234",
    "Fax": {
      "CountryCode": "61",
      "AreaCode": "",
      "text": ""
    },
    "Mobile": ""
  }
 }

How can I manipulate the 'FixedPhone' object to look more like the 'Fax' object in Javascript / JQuery? That is:
- Remove the "98221234" string
- Append the CountryCode and AreaCode properties (value of "" allowable)
- Set 'text' property of the value stored as the string value of FixedPhone ("98221234")

Help is greatly appreciated.
Many thanks

2
Contributors
1
Reply
17
Views
2 Years
Discussion Span
Last Post by piers
0

Hi,

This puts the change into a variable. I am not sure what you want to do with it so hopefully this gives you some flexibility.
The alert will show you what the data looks like in the variable.

var data = {
    "WorkPhone": {
        "Phone": {
            "FixedPhone": "98221234",
            "Fax": {
                "CountryCode": "61",
                "AreaCode": "",
                "text": ""
            },
            "Mobile": ""
        }
    }
};


data.WorkPhone.Phone.FixedPhone = { "CountryCode": "61",
                "AreaCode": "",
                "text": ""};

alert(JSON.stringify(data));
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.