如何使用 JSON.stringify() 打印不带大括号和引号的对象的值。
例如,当我这样做时:
var string = "this is a string";
var test = JSON.stringify(myJsonObject);
div.innerHTML = test;
输出是这样的:
{"vavlue":" this is a string"}
如何只输出实际字符串而不输出任何其他内容?
即:
this is a string
最佳答案
如果您的 JSON 对象如下所示:
myJsonObject = {"vavlue":" this is a string"};
您不需要字符串化来获取字符串值,您可以使用它:
myJsonObject.value
关于javascript - 打印不带引号和括号的 JSON 字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23918791/