有人知道我在干嘛吗?哈哈哈哈哈哈

let obj = '[{ "name":"runoob", "alexa":10000, "site":"m.runoob.com", "a": 1, "75": "555"}, { "name":"dfbxb", "alexa":3000, "site":"fdttrdom", "a": 1, "75": "5585"}]'

let [indexArr0, indexArr1] = [obj.indexOf("{"), obj.indexOf("}")]

let head = obj.substring(indexArr0+1, indexArr1).replace(/\s*/g,"")

let arr = head.split(",").map(item => item.replace(/\"/g,""))

arr.map(item => {
const [k, v] = item.split(":")
const tmp = {}
tmp[k] = v
return tmp
})
展开
此处空字符串于2021-12-13 18:24发布的图片
2
评论