如何JSON.parse忽略对象后的后缀

问题描述

我有一个输入字符串

let input = '{"username": "John Doe","email": "[email protected]"} trailing text'

我想 JSON.parse 它,但由于尾随文本而失败。

Uncaught SyntaxError: Unexpected token t in JSON at position 54
    at JSON.parse (<anonymous>)
    at <anonymous>:1:6

如何从忽略尾随文本的文本中解析 JSON 对象?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)