简体   繁体   中英

JSON Object parse javascript

I have a JSON object -

rows = [{name:"testname1" , age:"25"}, {name:"testname2" , age:"26"}]

I would like to extract the name information and put it into a variable like this.

name = "testname1, testname2";
var name = rows.map(function(r){
  return r.name
}).join(', ');

The above code will store the string testname1, testname2 into the name variable.

For more information on the .map function please see MDN .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM