如何使用jQuery将字符串转换为JSON对象
str = {'8': {'name': 'breeze bedsheet ', 'price': 1150, 'qty': 1, 'strid': '8', 'image': 'images/download_1.jpg'}, '10': {'name': 'neat and clean bedsheet ', 'price': 1150, 'qty': 2, 'strid': '10', 'image': 'images/images_2.jpg'}}
(str)
我想将此字符串转换为json对象
obj = json.parse
str = {'8': {'name': 'breeze bedsheet ', 'price': 1150, 'qty': 1, 'strid': '8', 'image': 'images/download_1.jpg'}, '10': {'name': 'neat and clean bedsheet ', 'price': 1150, 'qty': 2, 'strid': '10', 'image': 'images/images_2.jpg'}}
obj = JSON.parse(str)
I want to convert this string to JSON object but when i use JSON.parse method it gives me an error like
uncaught syntaxError: Unexpected token ' in JSON at position 1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是因为您使用
'
而不是”
It is because you use
'
instead of"