0

So this is my Json String

   {
      "method_name": "WSP.CC.GET.CARRIER.INFO",
      "calling_class": "com.fwdco.webservice.ScorpeoWebService",
      "error_code": "0",
      "contact_info": [
        [
          "name",
          "email",
          "phone"
        ]
      ]
    }

if i want to insert

           [
             "man"
             "[email protected]"
             "534534646"
            ]

in contact_info, so that final json String is :

         {
  "method_name": "WSP.CC.GET.CARRIER.INFO",
  "calling_class": "com.fwdco.webservice.ScorpeoWebService",
  "error_code": "0",
  "contact_info": [
    [
      "name",
      "email",
      "phone"
    ],
    [
       "man"
       "[email protected]"
       "534534646"
     ]
  ]
}

i tried to use splice and push function but it doesnt work. Help plz

3
  • You should add the splice and push you tried... Perhaps you can simply push without a splice? contact_info.push(["man", "[email protected]", "534534646"]) Commented Oct 8, 2014 at 18:38
  • i tried data.contact_info.push(newcontact) but it gives "contact_info": [ [ "name", "email", "phone" ], [ [ "man" "[email protected]" "534534646" ] ] ] I get this structure Commented Oct 8, 2014 at 18:39
  • Your array needs to be delimited: [ "man", "[email protected]", "534534646" ] Commented Oct 8, 2014 at 18:43

2 Answers 2

1

Give a try to this one: http://jsfiddle.net/csdtesting/97mvba88/

var obj = {
  "method_name": "WSP.CC.GET.CARRIER.INFO",
  "calling_class": "com.fwdco.webservice.ScorpeoWebService",
  "error_code": "0",
  "contact_info": [
    [
      "name",
      "email",
      "phone"
    ]
  ]

};


obj.contact_info.push(["man", "[email protected]", '534534646']);
console.log(obj);
console.log(obj.contact_info);

Sign up to request clarification or add additional context in comments.

Comments

0

If you are using JavaScript, here is a solution:

var myObject = {
    "method_name": "WSP.CC.GET.CARRIER.INFO",
    "calling_class": "com.fwdco.webservice.ScorpeoWebService",
    "error_code": "0",
    "contact_info": [
         [
           "name",
           "email",
           "phone"
         ]
    ]
};

myObject.contact_info.push([
  "man",
  "[email protected]",
  "534534646"
]);

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.