Trying to parse JSON/XML - works fine on iPhone, not on Android
Okay, I'm trying to pull data from the ReadItLater API and parse it and dump it to a table. Pretty simple stuff, right. I've removed the Ti.API.info lines I'm using for debugging and I'm not going to share my RIL user info, but you're welcome to play with my API key, if you want.
Here's my code:
var xhr = Titanium.Network.createHTTPClient();
xhr.onload = function()
{
var data = JSON.parse(this.responseText);
var itemList = data.list;
var x = 0;
for(var i in itemList)
{
var thisItem = itemList[i];
Ti.API.info('Article Title: ' + thisItem.title);
}
};
xhr.open('POST', 'https://readitlaterlist.com/v2/get');
xhr.send({
format: 'json',
username: '--username--',
password: '--password--',
apikey: '7f5dfZc6T730xy6aobA2e66Sb7gdk507'
});
Now, when I run this on the iPhone, it'll return the actual title nodes in the JSON tree, but on Android it returns null (the list
object being undefined
).
Any idea what's going on? I was up all night trying to figure this out and came up with nothing so I'm hoping you guys can help. Thanks in advance!
2 Answers
-
Accepted Answer
Shouldn't it be / try :
var data = eval('('+this.responseText+')');
instead of:
var data = JSON.parse(this.responseText);
Then see what you get if you output:
Ti.API.info(data);
-
Have you tried with a new build from our CI server?
Our continuous integration (CI) system provides updated builds approximately 30 minutes or less after a change has been committed to github. Please refer to our Continuous Builds for Download guide for obtaining one for your platform.