Javascript getJSON函数无法检索完整结果 [英] Javascript getJSON function not retrieving full results
本文介绍了Javascript getJSON函数无法检索完整结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
伙计,
以下功能似乎部分有效。来自API的返回JSON似乎被切断,随后的JSON.parse中断。
Folks, The following function seems to work partially. The returning JSON from the API seems to get cut off, and the subsequent JSON.parse breaks.
输出:
{
"license": {
"S":
undefined:1091
"S":
^
SyntaxError: Unexpected end of input
at Object.parse (native)
at IncomingMessage.<anonymous> (/blah/base.js:112:32)
at IncomingMessage.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:920:16
at process._tickCallback (node.js:415:13)
功能:
getJSON = function(options, onResult){
//console.log("rest::getJSON");
var prot = options.port == 8443 ? https : http;
var req = prot.request(options, function(res)
{
var output = '';
console.log(options.host + ':' + res.statusCode);
res.setEncoding('utf8');
res.on('data', function (chunk) {
output += chunk;
});
res.on('end', function() {
console.log("BREAK", output)
var obj = JSON.parse(output);
onResult(res.statusCode, obj);
});
});
req.on('error', function(err) {
res.send('error: ' + err.message);
});
req.end();
};
推荐答案
解决,将API和管理员计算机上的节点升级到v0.10.23问题消失了。
Solved, After upgrading node on API and Admin machines to v0.10.23 the problem went away.
这篇关于Javascript getJSON函数无法检索完整结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文