我需要从json字符串创建一个JSON对象。我试过了JSON.parse(json-string)
,但我收到了错误:
SyntaxError:意外的令牌o
但是当我在Android JSONObject(json-string)
中运行相同的字符串时,我得到了无错误
HTTP.get(url, function (error, response) {
if (response) {
var content = JSON.parse(response);
console.log(content);
我做错了吗?不是response
包含json-string而没有其他未经修改的内容?感谢
答案 0 :(得分:0)
response
是一个对象。您需要JSON.parse(response.content)
或response.data
。
结果对象的内容:
statusCode 号码
数字HTTP结果状态代码,或者出错时为null。
内容 字符串
HTTP响应的正文作为字符串。
数据 对象或null
如果响应标头指示JSON内容,则包含 解析为JSON对象的文档正文。
标题 对象
来自响应的HTTP标头字典。