Need to create array of json object in javascript

Expected Json Response:

[ { "country": "Tanzania, United Republic of", "isoCode": "TZ", "phoneCode": 255 }, { "country": "Australia", "isoCode": "AU", "phoneCode": 61 }, { "country": "Belgium", "isoCode": "BE", "phoneCode": 32 } ]

Javascript code:

var respObj = response.content.asJSON;

response.content = '';

response.headers['Content-Type'] = 'application/json';

var array = response.content.asJSON;

array.country = []; for( i=0;i<respObj.length;i++) { //alert(response[i].Name); array.country.push({"country":respObj[i].country,"isoCode":respObj[i].isoCode,"isd_code":respObj[i][i].isd_code}) }

i am not able to array of json object. data population is missing and returning as empty.

0 1 1,070
1 REPLY 1

@hari prasath

I see you have the expected response, can you also share the response you get that you are trying to change. What are you getting in the response.content ?