3 回答
TA贡献1864条经验 获得超2个赞
您可以使用 JSON 方法 stringify()
constsummary_data=[
{
Geo: "US West",
MeetingHash: "Hold/Uncategorized",
count: 65
},
{
Geo: "NSU",
MeetingHash: "Hold/Uncategorized",
count: 9
},
{
Geo: "US East",
MeetingHash: "Hold/Uncategorized",
count: 3
}
];
console.log(JSON.stringify(summary_data));
您的 JSON 将被转换为字符串。
TA贡献1842条经验 获得超21个赞
您可以使用JSON.stringify
试试这个代码:
const summary_data=[{Geo: "US West", MeetingHash: "Hold/Uncategorized", count: 65},{Geo: "NSU", MeetingHash: "Hold/Uncategorized", count: 9}, {Geo: "US East", MeetingHash: "Hold/Uncategorized", count: 3}];
var str = JSON.stringify(summary_data)
console.log(str)
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
TA贡献1815条经验 获得超12个赞
尝试使用JSON.stringify
const summary_data=[{Geo: "US West", MeetingHash: "Hold/Uncategorized", count: 65},
{Geo: "NSU", MeetingHash: "Hold/Uncategorized", count: 9},{Geo: "US East", MeetingHash: "Hold/Uncategorized", count: 3}];
// prints as string
console.log(JSON.stringify(summary_data));
// prints as formatted string
console.log(JSON.stringify(summary_data, null, 4));
// prints as <br> concatenated string
var str = "";
$.each(summary_data, function(key, entry) {
str += JSON.stringify(entry) + "<br>";
});
console.log(str);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
添加回答
举报