🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
区别:字符串比对象,在{}之外<span style="color:red;">多俩引号</span>。数组中,包含<span style="color:red;">多个对象</span> ``` json var obj = {"name":"zhangsan","sex":"男","age":"24"}; //json对象 console.log(obj.name); console.log(typeof obj); var objToStr = JSON.stringify(obj); //对象转字符串 console.log(objToStr); var str = '{"name":"zhangsan","sex":"男","age":"24"}'; //json字符串 console.log(str); console.log(typeof str); var strToObject = JSON.parse(str); //字符串转对象 console.log(strToObject); var arr = { //json数组 "employees": [ { "firstName":"John" , "lastName":"Doe" }, { "firstName":"Anna" , "lastName":"Smith" }, { "firstName":"Peter" , "lastName":"Jones" } ] }; ```