我有一个数组附加到html元素的data-categories属性,如下所示:
data-categories='["Commit Sha: 2ee57d5<br>Commit Date: 2017-05-21 14:29:00 UTC<br>Commit Message: remove verify option\n\ngit-s...<br>ruby 2.5.0dev (2017-05-21 trunk 58832) [x86_64-linux]", "Commit Sha: 48070ce<br>Commit Date: 2017-05-21 16:45:35 UTC<br>Commit Message: downloader cache\n\n* tool/do...<br>ruby 2.5.0dev (2017-05-21 trunk 58833) [x86_64-linux]", "Commit Sha: 47f2bd9<br>Commit Date: 2017-05-21 19:25:19 UTC<br>Commit Message: Use should_receive expectat...<br>ruby 2.5.0dev (2017-05-22 trunk 58835) [x86_64-linux]", "Commit Sha: 913afdf<br>Commit Date: 2017-05-21 19:27:08 UTC<br>Commit Message: test_string.rb,test_symbol....<br>ruby 2.5.0dev (2017-05-22 trunk 58836) [x86_64-linux]", "Commit Sha: 40bc846<br>Commit Date: 2017-05-21 19:28:48 UTC<br>Commit Message: string.c: fix String\#{casec...<br>ruby 2.5.0dev (2017-05-22 trunk 58837) [x86_64-linux]"]'
虽然这个数组似乎是有效的json,但当我调用$('.element').data('categories')
时,它会返回非解析的字符串。当我致电JSON.parse($('.element').data('categories'))
时,我会收到无法识别#
的解析错误。
我认为在字符串中使用\#{
会出现问题,但无法弄清楚是什么。
这可能是个错误吗?
由于