这可能是一件非常微不足道的事情,但我在该领域的经验很少,所以它可能会变得非常复杂。
基本上,我试图将一堆 HTML 数据属性渲染到它们的 JSON 等价物中。例如,我有以下 HTML 标记(因为它太长了,所以我剪掉了它):
<span class="play-queue play-queue-med-small" data-json=
"{"id":
4276028,
"selected":
false,"type":
"track","sku":
"track-4276028","name":
"This Is What It Feels Like feat. Trevor Guthrie","trackNumber":
2,"active":true,"mixName":
"W&
W Remix","title":
"
This Is What It Feels Like feat. Trevor Guthrie
(W&W Remix)","slug":
"
;this-is-what-it-feels-like-feat-trevor-guthrie-w-and-w-remix",
"isrc":"
NLF711303293","releaseDate":
"2013-04-05","publishDate":"2013-04-05","sampleUrl":"
由此,我想将 data-json 属性呈现为 JSON 记录,如下所示:
{
“key1”:”value1”,
“key2”:”value2”,
...
“keyN”:”valueN”
}
有没有办法做到这一点?也许是一种方法(在 C# 或 Java 中),或者一些解决方法?
提前一百万谢谢!