var test = {
profile: {
name: "Mani",
add: "chennai",
Edu: {
maxDegree: "BE",
Edu:{
School:"Chennai"
}
}
}
}
我需要这样:
var test = [{ profile: [{ name: "Mani", add: "chennai", Edu: [{ maxDegree: "BE" }] }] }];
答案 0 :(得分:1)
您应该在您的favrouite搜索引擎中搜索它。 JSON.stringify是你的朋友。从链接了解有关它的更多信息。 https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
JSON.stringify(test)
答案 1 :(得分:0)
如果对象显示为String,则可以使用Javascript
var test='
{
profile: {
name: "Mani",
add: "chennai",
Edu: {
maxDegree: "BE",
Edu:{
School:"Chennai"
}
}
}
}';
JSON.parse(test);
额外参考:https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse