简体   繁体   English

如何使用 javascript 将此字符串转换为 json?

[英]How do I convert this string into json with javascript?

How do I parse string into json with javascript?如何使用 javascript 将字符串解析为 json?

"[{'Name': \"O'BRIEN DEIRDRE\", 'Text': 'Hello'}]" "[{'Name': \"O'BRIEN DEIRDRE\", 'Text': 'Hello'}]"

I need to change all single quote to double quote, but I need to keep the single quote of O'BRIEN我需要将所有单引号更改为双引号,但我需要保留 O'BRIEN 的单引号

Maybe this can fix your problem: https://regexr.com/55t8o也许这可以解决您的问题: https://regexr.com/55t8o

Edit: If the link is deprecated the regex expression should be '([a-zA-Z]*)' and replace it with "$1"编辑:如果不推荐使用链接,则正则表达式应为 '([a-zA-Z]*)' 并将其替换为 "$1"

I also agree with Taplar who commented that it would probably be better if you found out why it's using ' instead of " and not use regex. Hope this helps我也同意 Taplar 的观点,他评论说如果你发现它为什么使用 ' 而不是 " 并且不使用正则表达式可能会更好。希望这会有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM