Can't execute JSON. Rules any string with httpRequest
I have my own webservice which I make a POST request from the Analyze function.
A few days ago I was able to Parse()
JSON just fine , now I am getting a bunch of [object Object] and undefined properties . I am not changing anything on my webservice, I even tried to rollback but none seem to work.
What my code looks like:
Parse.Cloud.httpRequest({
method: 'POST',
url: 'http://MYWEBSERVICE.php',
body: {
userTia: jsoncontent,
userPass: jsoncontent,
userUnidade: jsoncontent
},
success: function(httpResponse) {
console.log(httpResponse.text);
var tiaJsonParsed = JSON.parse(httpResponse.text);
console.log("Response: " + httpResponse.text);
console.log("JsonParsed: " + tiaJsonParsed[1]);
console.log("JsonParsed: " + tiaJsonParsed[1].nome)
},
error: function(httpResponse) {
console.error('Request failed with response code ' + httpResponse.status);
}
});
httpResponse.text
gives me valid JSON, exactly what I expect. But all those console.logs give me:
[object Object]; 1: [object Object]; 2: [object Object]; 3: [object Object]; 4: [object Object]; 5: [object Object]; 6: [object Object]; 7: [object Object];
Yes, that's right, it's an array of objects, that's right. But it shouldn't be an Object.
I even tried:
for (var property in tiaJsonParsed) {
output += property + ': ' + tiaJsonParsed[property]+'; ';
}
console.log('OUTPUT:' + output);
Only undefined .
var tiaJsonParsed = JSON.parse(JSON.stringify(httpResponse.data));
var tiaJsonParsed2 = JSON.parse(JSON.stringify(httpResponse.text));
Same.
So what am I doing wrong here? Does Parse.com change anything between this week and last week? Because it suddenly stops and I have no more ideas.
source to share
No one has answered this question yet
Check out similar questions: