我有一个这样的Javascript对象:
obj = "[
{
title: "Sean Kingston1",
duration: parseInt("71", 10),
},
{
title: "Sean Kingston2",
duration: parseInt("71", 10),
},
]"
有没有一种方法将它转换为Ruby哈希表?
我尝试使用JSON.parse和JSON.load。 但两者都会抛出异常。
JSON::ParserError: lexical error: invalid string in json text.
{ title: "Sean Kingston1
(right here) ------^
是否有通用解决方案,还是我应该使用正则表达式,然后在Ruby中构建哈希表?