我需要帮助来转换像这样的JSON
{ "短语":[{ " content_type":" text", " title":" blablabla 1", "有效载荷":" blabla", " text":"" },{ " content_type":" text", " title":" blablabla 2", "有效载荷":" blabla", " text":"" },{ " content_type":" text", " title":" blablabla 3", "有效载荷":" blabla", " text":"" }], " ogg":" true", " custom":" true" }
将函数中使用的对象作为"选项"(或"设置",你知道)就像这样
function(){
options = {
phrase: [
{
content_type: "text",
title: "blablabla 1",
payload: "blabla",
text: ""
},
{
content_type:"text",
title:"blablabla 2",
payload: "blabla"
},
{
content_type:"text",
title:"blablabla 3",
payload: "blabla"
}
],
ogg: true,
custom: true
}
return options;
}
无论如何都可能吗?谢谢!
答案 0 :(得分:1)
你可以用这个
var obj = JSON.parse(options);
它将为您提供对象,并使用点(。)运算符可以访问对象内的数据