I have a simple javascript object with some device information including last known geolocation (longitude and latitude only). I'm using JSON.stringify to turn this object in to JSON, but the one variable I have that isn't boolean/text/number gets ignored.
exports.CallContext = function() {
var deviceId;
var applicationId;
var userLocation = {lat:0, lon:0};
var operatingSystem;
this.create = function(b) {
this.deviceId = Titanium.Platform.id;
this.applicationId = Alloy.Globals.appId;
Titanium.Geolocation.getCurrentPosition(function(e) {
if(e.error) {
Ti.API.info(e.error);
} else {
this.userLocation = {lat:e.coords.latitude, lon:e.coords.longitude};
}
});
this.operatingSystem = Titanium.Platform.version;
};
};
After doing JSON.stringify(myCallContext);
I get a JSON object with deviceId, applicationId and operatingSystem (etc., some omitted), not sure why it isn't including userLocation. Tried turning it in to an array, didn't work still, and still doesn't include it when I get rid of the getCurrentLocation and leave it with dummy info.
this.userLocation
? – Dragon Mar 25 '15 at 12:16