[英]How to convert a math equation string to json structure and parse using JavaScript?
[英]How to Convert JSON String into new JSON Object with other structure using Javascript
javascript無法讀取json字符串,幫助我將其轉換為javascript JSON對象
{
text: {
name: "ROOT"
},
HTMLclass: "blue",
image: "images/no_member.png",
children: [
{
connectors: {
style: {
stroke: "#000000"
}
},
text: {
name: "SAYED"
},
HTMLclass: "blue",
image: "images/no_member.png",
},
{
connectors: {
style: {
stroke: "#000000"
}
},
text: {
name: "DIDAR"
},
HTMLclass: "blue",
image: "images/no_member.png",
}
]
}
JSON.parse()可能是答案,您應該將鍵包含在“”中。
但是JSON(JavaScript對象表示法)的意思是“像Javascript對象一樣的表示法”。 所以本來想。 像下面這樣;
var obj = {
text: {
name: "ROOT"
},
HTMLclass: "blue",
image: "images/no_member.png",
children: [
{
connectors: {
style: {
stroke: "#000000"
}
},
text: {
name: "SAYED"
},
HTMLclass: "blue",
image: "images/no_member.png",
},
{
connectors: {
style: {
stroke: "#000000"
}
},
text: {
name: "DIDAR"
},
HTMLclass: "blue",
image: "images/no_member.png",
}
]
};
console.log(obj);
謝謝。
您需要JSON.parse()。
有關更多詳細信息,請參見JSON 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.