How do I stringify an array of objects?

前端 未结 3 1001
逝去的感伤
逝去的感伤 2021-01-13 04:48

I have created an array of objects that needs to be stored and kept for another page.

The array of objects is similar to this:

var cheese_array = [
          


        
3条回答
  •  攒了一身酷
    2021-01-13 05:40

    Update JSON with ,(Comma) in

     name: "Blue Stilton",
        age: "13",
        smelly: true
    

    var cheese_array = [
      {
        name: "Chedder",
        age: "34",
        smelly: true
      },
      {
        name: "Brie",
        age: "4",
        smelly: false
      },
      {
        name: "Blue Stilton",
        age: "13",
        smelly: true
      }
     ];
    
    var details = JSON.stringify(cheese_array);
    alert(details);

提交回复
热议问题