1.向数组中添加json数据

var arr=[];
var json = {"name":"apple","color":"red"}
arr.push(json)
console.log(arr)

 

返回结果:

数组新增,修改json数据

 

2.新增 json 键值对

var fruit =[{"name":"banana"}];  
fruit[0].color='yellow'
console.log(fruit)

 

返回结果:

数组新增,修改json数据

 

相关文章:

  • 2021-06-09
  • 2022-12-23
  • 2021-04-09
  • 2022-03-09
  • 2022-12-23
  • 2022-12-23
  • 2021-12-25
  • 2021-08-27
猜你喜欢
  • 2021-09-09
  • 2022-01-25
  • 2021-12-05
  • 2022-12-23
  • 2021-07-14
  • 2021-09-05
  • 2021-06-26
相关资源
相似解决方案