Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.1k views
in Technique[技术] by (71.8m points)

如下,JS怎么去掉数组内的单引号?

let obj = [ 
  '{"cardNo":"CJ147821","contact":"contact","remark":"remark","remarkOrgName":"remarkOrgName","tel":"tel"}',
  '{"cardNo":"CJ147821","contact":"contact","remark":"remark","remarkOrgName":"remarkOrgName","tel":"tel"}' 
]

怎么去掉对向两侧的单引号,让obj成为一个真正的JSON


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
const newObj = obj.map(item => JSON.parse(item))

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...