js对象转换为json字符串

JavaScript的对象是一组由键-值组成的无序集合,例如:

var person = {
    name: 'Bob',
    age: 20,
    tags: ['js', 'web', 'mobile'],
    city: 'Beijing',
    hasCar: true,
    zipcode: null
};

  转化为JSON字符串要用JSON.stringify()方法。具体实例如下:

猜你喜欢

转载自www.cnblogs.com/ttty/p/10429138.html