JSON.parse()无法在云代码中正确解析为JSON

时间:2015-12-23 02:11:15

标签: javascript json parse-platform cloud-code

我有一个云代码作业,应该启动一个httpRequest并存储一个类中收到的JSON。到目前为止,JSON是从httpResponse返回的,但JSON.parse()似乎无法正常工作。这是我的云代码工作的一部分:

var str = httpResponse.text;
console.log("news " + str);
var jsonNews = JSON.parse(str);
console.log(jsonNews);

以下是我的日志: 在console.log("news " + str);之后我有了这个:

news {"name":"News","count":71,"frequency":"Daily","version":3,
"newdata":true,"lastrunstatus":"success","thisversionstatus":"success",
"nextrun":"Wed Dec 23 2015 17:52:28 GMT+0000 (UTC)",
"thisversionrun":"Tue Dec 22 2015 17:52:28 GMT+0000 (UTC)",
"results":{"collection1":[{"date":"Dec-22:","headline":
{"href":"http://ghanafa.org/pages/gfa/201512/11174.php",
"text":"GFA holds Media & Marketing for Premier/... (truncated)

在我console.log(jsonNews);之后:

{"name":"News","count":71,"frequency":"Daily","version":3,
"newdata":true,"lastrunstatus":"success","thisversionstatus":"success",
"nextrun":"Wed Dec 23 2015 17:52:28 GMT+0000 (UTC)",
"thisversionrun":"Tue Dec 22 2015 17:52:28 GMT+0000 (UTC)",
"results":{"collection1":[{},{},{},{},{},{},{},{},{},{},{},{},{},{},
{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},
{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},
{},{},{},{},{},{},{},{},{},{}],"collection2":[{}]}}

为什么我在JSON对象中丢失数据?它真的是云代码中的JSON.parse()会导致问题吗?如果是这样,我该如何防止这种情况?

0 个答案:

没有答案