<分区>
我有一个 div,它以 json 格式输出文本:
HTML
<div id="myMap"></div>
JS
$('#myMap').text(JSON.stringify(out[0], null, 2));
这给了我:
{ "name": "Leopardi", "children": [ { "name": "Vita", "children": [ { "name": "Ubriacone" } ] }, { "name": "Poesie", "children": [ { "name": "L'infinito" } ] } ] }
现在我需要将其设置为能够读取它的变量,这就是我正在做的,但我什么也没得到:
var root = $('#myMap').text();
我试图让输出像这样:
var root = {
"name": "flare",
"url": "http://google.com",
"children": [
{
"name": "an...